整数解
http://acm.hdu.edu.cn/showproblem.php?pid=2092
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 31406 Accepted Submission(s): 11021例如:
x + y = 9,x * y = 15 ? 找不到这样的整数x和y
1+4=5,1*4=4,所以,加起来等于5,乘起来等于4的二个整数为1和4
7+(-8)=-1,7*(-8)=-56,所以,加起来等于-1,乘起来等于-56的二个整数为7和-8
9 15 5 4 1 -56 0 0
No Yes Yes
#include <stdio.h>
#include <math.h>
main()
{ int n,m,x;
while (1)
{ scanf ("%d%d",&n,&m);
if (n==0 && m==0) break;
x = sqrt (n*n-4*m);
if (x*x == n*n-4*m && (n+x)%2 == 0)
printf ("Yes\n");
else printf ("No\n");
}
return 0;
}
928



被折叠的 条评论
为什么被折叠?



