Integer solution
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 25460 Accepted Submission (s): 8911
Problem description There are two integers, they add up equal to an integer, multiply and equal to another integer, whether they are true or false, that is, this integer does not exist, it is a bit doubt, you can quickly answer? Seems to be programmed only.
For example:
x + y = 9,x * y = 15? No such integer x and y are found
1+4=5,1*4=4, so, add up equals 5, multiply up equals 4 of two integers are 1 and 4
7+ (-8) =-1,7* (-8) =-56, so, add up equals-1, multiply equals-56 of two integers are 7 and 8
Input data is a paired integer n,m ( -10000<n,m<10000), which represents the integer and the product respectively, and if both are 0, the input ends.
Output requires only a "Yes" or "no" for each N and M, either explicitly or without the integer.
Sample Input9 155 41-560 0 Sample Outputnoyesyes Authorqianneng source Meet the new semester-super easy version super easy version
1#include <iostream>2#include <cstdio>3#include <cstring>4#include <cmath>5 6 using namespacestd;7 8 #defineN 519 #defineINF 0x3f3f3f3fTen One intMain () A { - intN, M; - the while(SCANF ("%d%d", &n, &m), n+m) - { - //int flag = 0; - + Doublex =1.0* (N+sqrt (n*n-4*M))/2; - Doubley =1.0* (N-sqrt (n*n-4*M))/2; + A if(x = = (int) x && y = = (int) y) atprintf"yes\n"); - Else -printf"no\n"); - } - return 0; -}
Study hard and live seriously. Think hard and study hard.
Integer solution (Hdu 2092