Now Access to Gemini (Google) : Really beat to ChatGPT ?

Hello Equation Codechef Solution -August long challeng -2022

 Codechef August Long challenge 2022 

X. Your task is to tell whether there exist two positive integers a and b (a \gt 0, b \gt 0) such that

2\cdot a + 2\cdot b + a\cdot b = X

If there exist positive integers a and b satisfying the above condition print YES, otherwise print NO.

Link of the problem : Click Here to see See

Codechef Problem August long challenge 2022

Code : 

/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner scan = new Scanner (System.in);
int T = scan.nextInt();
for(int t = 0 ; t < T ; t++){
    long X = scan.nextInt();
    long a = 0 ;
    long b = 0 ;
    boolean flag = false;
    for(int i = 1;  i < (int)Math.pow(X,0.5)  ; i++){
        long first = X - (2 * i);
        long second = (i+2);
        if(first % second == 0){
          
            flag = true;
            break;
        }
        
    }
  
    if(flag){
        System.out.println("yes");
    }
    else{
        System.out.println("no");
    }
}
}
}

To join the telegram channel for more update : Join Now

Comments

Post a Comment

Any Query Regarding Article Ask me in comment