[恢]hdu 2092

2011-12-16 04:16:12

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2092

题意:中文。

mark:可以搜,但是慢。可以配方后得:若n*n-4*m为完全平方数,有解,否则无解。

代码:

# include <stdio.h>
# include <math.h>


int test(int n, int m)
{
int buf = n*n-4*m ;
int p = sqrt(n*n-4*m) ;
if (buf < 0) return 0 ;
return (p*p == n*n-4*m) ;
}


int main ()
{
int n, m ;
while (~scanf ("%d%d", &n, &m) && (n||m))
puts (test(n, m) ? "Yes" : "No") ;
return 0 ;
}



原文地址:https://www.cnblogs.com/lzsz1212/p/2314903.html