Existence Code chef.
Posted on | Saturday, 20 May 2023 | No Comments
Problem
Chef has two variables X and Y. He wants to find out whether the variables satisfy the equation:
- X4+4⋅Y2=4⋅X2⋅Y
Input Format
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two integers X and Y, as mentioned in statement.
Output Format
For each test case, output YES
if the variables X and Y satisfy the given equation, NO
otherwise.
You may print each character in uppercase or lowercase. For example, Yes
, YES
, yes
, and YeS
are all considered the same.
Constraints
- 1≤T≤1000
- 1≤X≤109
- 1≤Y≤1018
Sample 1:
5
2 2
4 4
3 6
8 32
200000000 20000000000000000
YES
NO
NO
YES
YES
Explanation:
Test case 1: Given X=2 and Y=2. Here, 24+4⋅22=4⋅22⋅2=32.
Test case 2: Given X=4 and Y=4. Here, 44+4⋅42=320 which is not equal to 4⋅42⋅4=256.
Test case 3: Given X=3 and Y=6. Here, 34+4⋅62=225 which is not equal to 4⋅32⋅6=216.
Test case 4: Given X=8 and Y=32. Here, 84+4⋅322=8192 which is equal to 4⋅82⋅32=8192.
Test case 5: Given X=2⋅108 and Y=2⋅1016. Here, (2⋅108)4+4⋅(2⋅1016)2=32⋅1032 which is equal to 4⋅(2⋅108)2⋅(2⋅1016)=32⋅1032.
code
for i in range(int(input())):
a,b=map(int,input().split())
if (a**4)+4*b**2==4*a**2*b:
print("YES")
else:
print("NO")

Comments
Categories
Archives
- May 2023 (30)
Leave a Reply