Description
有如下四个式子: X+Y=A X^2+Y^2=B X^3+Y^3=C X^4+Y^4=D 给出A、B、C、D四个值,你能判断A、B、C、D这四个值能同时让上面四个式子成立吗?
Input
有多组测试数据。每组中都输入四个整数,分别是A、B、C、D。0<=A,B,C,D<=50
Output
如果这四个值能同时让上面四个式子成立,输出“Y”,否则输出“N”。 每组输出数据占一行。
Sample Input
1 3 4 5
Sample Output
N
#include<iostream>
using namespace std;
int sq(int a)
{
return a*a;
}
int main()
{
int a , b , c , d;
while (cin >>a >> b >> c >> d)
{
if ( (3*b-sq(a)) * a == 2*c && 2*sq(b) - sq(sq(a)-b) == 2*d )
cout << "Y" << endl;
else
cout << "N" << endl;
}
}