Jam has a math problem. He just learned factorization. He is trying to factorize ax^2+bx+cax2+bx+c into the form of pqx^2+(qk+mp)x+km=(px+k)(qx+m)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.
The first line is a number TT, means there are T(1 \leq T \leq 100 )T(1≤T≤100) cases
Each case has one line,the line has 33 numbers a,b,c (1 \leq a,b,c \leq 100000000)a,b,c(1≤a,b,c≤100000000)
You should output the "YES" or "NO".
2
1 6 5
1 6 4
YES
NO
The first case turn x^2+6*x+5x2+6∗x+5 into (x+1)(x+5)(x+1)(x+5)
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD doublea
#define MAX 10100
#define mod 10007
using namespace std;
int ans[MAX];
int main()
{
int n,m,j,i,t,k;
int a,b,c,Min1,Min2;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&a,&b,&c);
Min1=min(a,10000);
Min2=min(c,10000);
k=1;n=m=1;
for(i=1;i<=Min2;i++)
{
n=c/i;
if(n*i==c)
ans[k++]=i;
}
int flag=0;
for(i=1;i<=Min1;i++)
{
m=a/i;
if(i*m==a)
{
for(j=1;j<k;j++)
{
if((i*ans[j]+m*(c/ans[j])==b)||(m*ans[j]+i*(c/ans[j])==b))
{
flag=1;
break;
}
}
}
if(flag)
break;
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}