hdu 5615 (Jam's math problem)

来源:互联网 发布:暴风vr电视直播软件 编辑:程序博客网 时间:2024/06/06 16:31

 数学  Jam's math problem

Description

Jam has a math problem. He just learned factorization. 
He is trying to factorize $ax^2+bx+c$ into the form of $pqx^2+(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.

Input

The first line is a number $T$, means there are $T(1 \leq T \leq 100 )$ cases 

Each case has one line,the line has $3$ numbers $a,b,c (1 \leq a,b,c \leq 100000000)$

Output

You should output the "YES" or "NO".

Sample Input

21 6 51 6 4

Sample Output

YESNO          

题意:ax^2+bx+c能否转化成十字相乘的形式((pm+kq=b))

题解:若能转化,则x必为有理数,求根公式 x=(-b±√△)/2a,判断 △是否为完全平方数。

 

<span style="font-size:18px;">#include<cstdio>#include<cmath>using namespace std;int main(){int t;long long a,b,c;scanf ("%d",&t);while (t--){scanf ("%lld %lld %lld",&a,&b,&c);long long m=b*b-4*a*c;long long k=sqrt(m);if (k*k==m)printf ("YES\n");elseprintf ("NO\n");}return 0;} </span>


0 0