HDU-5615-Jam's math problem(方程求解)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 870 Accepted Submission(s): 415
He is trying to factorize ax2+bx+c into the form of pqx2+(qk+mp)x+km=(px+k)(qx+m).
He could only solve the problem in which p,q,m,k are positive numbers.
Please help him determine whether the expression could be factorized with p,q,m,k being postive.
Each case has one line,the line has 3 numbers a,b,c(1≤a,b,c≤100000000)
/*2016.3.15*/
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
long long a,b,c,q,p,k,m,n,h;
double j;
scanf("%I64d",&n);
while(n--)
{
scanf("%I64d%I64d%I64d",&a,&b,&c);
j=b*b-4*a*c;
//m=b*b-4*a*c;
if(j>=0)
{
j=sqrt(j);//q=sqrt(m)
h=(int)j;//強制類型轉換
if(j-h)//if(q*q!=m)
printf("NO\n");
else
printf("YES\n");
}
else
printf("NO\n");
}
return 0;
}