Description
Jam has a math problem. He just learned factorization.
He is trying to factorize![](https://i-blog.csdnimg.cn/blog_migrate/0815e7e68da82e60bdb79395822f6d97.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e3f420d38eb1b6e230fcbf29a6d432c3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6819ad02b70c45921b71f613da72f0f8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
into the form of
![](https://i-blog.csdnimg.cn/blog_migrate/058510b0f32a8143712905f626b0a4da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7e24bd8f6c465e2b25acd953fd262746.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e3f420d38eb1b6e230fcbf29a6d432c3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7e24bd8f6c465e2b25acd953fd262746.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b5879407f132df93e22c848f7e7176b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9c38887f58a15d10c8b7e0e22ef29a9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/058510b0f32a8143712905f626b0a4da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b5879407f132df93e22c848f7e7176b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9c38887f58a15d10c8b7e0e22ef29a9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b203c1c015063a750958b22412a78ae.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/058510b0f32a8143712905f626b0a4da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b5879407f132df93e22c848f7e7176b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7e24bd8f6c465e2b25acd953fd262746.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9c38887f58a15d10c8b7e0e22ef29a9.png)
.
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.
He is trying to factorize
![](https://i-blog.csdnimg.cn/blog_migrate/0815e7e68da82e60bdb79395822f6d97.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e3f420d38eb1b6e230fcbf29a6d432c3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6819ad02b70c45921b71f613da72f0f8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0df7c7916c37764e51472dfc343a3bf8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/058510b0f32a8143712905f626b0a4da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7e24bd8f6c465e2b25acd953fd262746.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e3f420d38eb1b6e230fcbf29a6d432c3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7e24bd8f6c465e2b25acd953fd262746.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b5879407f132df93e22c848f7e7176b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9c38887f58a15d10c8b7e0e22ef29a9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/058510b0f32a8143712905f626b0a4da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b5879407f132df93e22c848f7e7176b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9c38887f58a15d10c8b7e0e22ef29a9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2b203c1c015063a750958b22412a78ae.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/058510b0f32a8143712905f626b0a4da.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0b5879407f132df93e22c848f7e7176b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7e24bd8f6c465e2b25acd953fd262746.png)
![](https://i-blog.csdnimg.cn/blog_migrate/82e20a3491b6554bca16b2e497c691bd.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e55d414846558ea8e1501b5ff737c782.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f9c38887f58a15d10c8b7e0e22ef29a9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
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.
Input
The first line is a number
, means there are
![](https://i-blog.csdnimg.cn/blog_migrate/1f80243d0ee60179b3bfaa08e2d41700.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1f80243d0ee60179b3bfaa08e2d41700.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
cases
Each case has one line,the line has
numbers
![](https://i-blog.csdnimg.cn/blog_migrate/0815e7e68da82e60bdb79395822f6d97.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6819ad02b70c45921b71f613da72f0f8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0df7c7916c37764e51472dfc343a3bf8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0815e7e68da82e60bdb79395822f6d97.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6819ad02b70c45921b71f613da72f0f8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0df7c7916c37764e51472dfc343a3bf8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1f80243d0ee60179b3bfaa08e2d41700.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1f80243d0ee60179b3bfaa08e2d41700.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1f80243d0ee60179b3bfaa08e2d41700.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
Each case has one line,the line has
![](https://i-blog.csdnimg.cn/blog_migrate/0ada33721851097372f8d91f91139fa0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0815e7e68da82e60bdb79395822f6d97.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6819ad02b70c45921b71f613da72f0f8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0df7c7916c37764e51472dfc343a3bf8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7df305c950c9fa1d7448a36af4049dc3.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0815e7e68da82e60bdb79395822f6d97.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6819ad02b70c45921b71f613da72f0f8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0078e2c51675107576ccab364cd305ec.png)
![](https://i-blog.csdnimg.cn/blog_migrate/0df7c7916c37764e51472dfc343a3bf8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d11c95e88ab4c8b84819401a4bd9aa72.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a22e580c04f29f0f25e4262eec591fd5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1b08ce66336b4f2b3a7b911c59c311d2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/9f61591de1c8a8c5f8c7d228814838c5.png)
Output
You should output the "YES" or "NO".
Sample Input
2 1 6 5 1 6 4
Sample Output
YES NO
Hint
The first case turn $x^2+6*x+5$ into $(x+1)(x+5)$
这个题我刚开始做的是用一个二维数组,把mpqk的所有情况全部列举出来,但是不知道为啥,一直wa,后来看别人代码都很简单,说是根号下德尔塔一定是整数,找了几个大神,也没解释出所以然,后来又看到另一种方法,跟我第一次的差不多,试着敲了一遍,就过了,真神奇!
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
__int64 p[10000010][2],q[10000010][2];
int main()
{
__int64 i,j,m,a,b,c,z,x;
scanf("%I64d",&m);
while(m--)
{
scanf("%I64d%I64d%I64d",&a,&b,&c);
int flag=0;
for(i=1;i*i<=a;i++)
{
if(a%i==0)
{
z=a/i;
for(j=1;j*j<=c;j++)
{
if(c%j==0)
{
x=c/j;
if(i*j+z*x==b||i*x+j*z==b)
{
flag=1;
break;
}
}
}
}
if(flag)
break;
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}