Y/N

来源:互联网 发布:智能机器人编程入门 编辑:程序博客网 时间:2024/06/08 20:07

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)
{
    returna*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;
}
}

0 0
原创粉丝点击