- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
Codechef August Long challenge 2022
you are given the positive Integer X. Your task is to tell whether there exist two positive integers a and b (a>0,b>0) such that
2⋅a+2⋅b+a⋅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
Thanks for the great content. I will also share with my friends & once again thanks a lot
ReplyDeleteLinkedIn Skill Assessment Answers
Linkedin C++ Assessment Answers 2022
Linkedin Java Assessment Answers 2022
Linkedin Python Assessment Answers 2022
LinkedIn R Programming Assessment Answers
Linkedin Rust Programming Assessment Answers
LinkedIn Go Programming Assessment Answers
LinkedIn Android Skill Assessment Answers
LinkedIn Machine Learning Skill Assessment Answer
Linkedin Cybersecurity Assessment Answers 2022
LinkedIn Agile Methodologies Skill Assessment Answer
LinkedIn .NET Framework Skill Assessment Answer
LinkedIn Bash Assessment Answers
LinkedIn Front End Development Assessment Answers
LinkedIn Front End Development Assessment Answers
Linkedin Ruby On Rails Assessment Answers
Linkedin Node JS Assessment Answers
LinkedIn CSS Assessment Answers
Linkedin GIT Assessment Answers
LinkedIn C# (C Sharp) Assessment Answers
LinkedIn Adobe Acrobat Assessment Answers
LinkedIn Microsoft Outlook Assessment Answers
LinkedIn Visio Assessment Answers
Linkedin Accounting Assessment Answers
LinkedIn Microsoft Excel Skill Assessment Answer
LinkedIn Microsoft PowerPoint Skill Assessment Answer