Question one hundred and thirty-two: natural number pair

Source: Internet
Author: User

Description


Know 2 natural numbers A, B, if A + B, A-B is the number of degrees, then A, B is the natural number pair. Write A program to determine whether the given two numbers A and B are natural number pairs.


Input

 


The first line has an integer T, indicating that there are T groups of test data. Line 2 ~ Row T + 1 has two data records A and B, where 0 <= A + B <= 2 ^ 31 and A> B.

 


Output


Output a row of test data for each group, including "YES" or "NO ". "YES" indicates that the number pair is a natural number pair; otherwise, "NO" is output ".


Sample Input

 


2
17 8
3 1


Sample Output

 


YES
NO

 

[Plain]
# Include <stdio. h>
# Include <math. h>
 
Int square (int m );
 
Int main ()
{
Int n;
Int;
Int B;

Scanf ("% d", & n );
 
While (n --)
{
Scanf ("% d", & a, & B );
 
If (square (a-B) & square (a + B ))
{
Printf ("YES ");
}
Else
{
Printf ("NO ");
}
If (n> 0)
{
Printf ("\ n ");
}
}
 
Return 0;
}
 
Int square (int m)
{
Int I;
Int flag = 0;
 
I = sqrt (m );
 
If (I * I = m)
{
Flag = 1;
}
 
Return flag;
}

# Include <stdio. h>
# Include <math. h>

Int square (int m );

Int main ()
{
Int n;
Int;
Int B;

Scanf ("% d", & n );

While (n --)
{
Scanf ("% d", & a, & B );

If (square (a-B) & square (a + B ))
{
Printf ("YES ");
}
Else
{
Printf ("NO ");
}
If (n> 0)
{
Printf ("\ n ");
}
}

Return 0;
}

Int square (int m)
{
Int I;
Int flag = 0;

I = sqrt (m );

If (I * I = m)
{
Flag = 1;
}

Return flag;
}

 


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.