Problem Description
Jam has a math problem. He just learned factorization. He is trying to factorizeAx^2+bx+cAX?2??+BX+C into the form ofpqx^2+ (QK+MP) x+km= (px+k) (qx+m)PQX?2?? +(qk+mp)x+km=(px+k) (qx+m). He could only solve the problem in which p,q,m,k is positive numbers. Please help him determine whether the expression could is factorized with P,q,m,k being postive.
Input
The first line was a number tT, means there is t (1 \leq t \leq)T(1≤t≤ 1 00) Cases
Each case have one line,the line have33 numbers a,b,c (1 \leq a,b,c \leq 100000000) a,b,c (1≤a,b,c ≤1000 00000 /span>
Output
You should output the "YES" or "NO".
Sample Input
21 6 51) 6 4
Sample OutputCopy
YESNO
Hintthe first Case turnX^2+6*x+5X ? 2 ?? +6∗x+< Span class= "Mord" >5 into (x+1) (x+5) (x+1) (x+5) Test instructions: give you a one-yuan two-time equation of three coefficients a, b,c asked if you can use a cross-multiplication method to decompose the formula: direct violence enumeration, of course, to optimize the enumeration method, otherwise it will time out, optimization: Because the maximum data is 100 million, 100 million can be decomposed into 10,000 by 10,000, Because then we break down two number must not be more than 10,000, first of all the factors of C exist in the array, and then in the calculation of all the factors of a, a test can be
#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 10007using 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");
Bestcoder Round #70 Jam ' s math problem (HDU 5615)