hdu5615 Jam's math problem (BestCoder Round #70)

18940 단어
Jam's math problem
 Time Limit: 2000/1000 MS (Java/Others)
 
 Memory Limit: 65536/65536 K (Java/Others)
문제 설명
Jam            ,            ,x^2+6x+5=(x+1)(x+5)x2+6x+5=(x+1)(x+5)
      ax^2+bx+cax2+bx+c => pqx^2+(qk+mp)x+km=(px+k)(qx+m)pqx2+(qk+mp)x+km=(px+k)(qx+m)p,q,m,kp,q,m,k

입력 설명
   TTT(1 \leq T \leq 100 )T(1T100)TT   :
      ,      a,b,ca,b,c(1 \leq a,b,c \leq 100000000)(1a,b,c100000000)

출력 설명
      ,  "YES"  "NO".

입력 샘플
2
1 6 5
1 6 4

출력 샘플
YES
NO

Hint
         (x+1)(x+5)=x^2+6*x+5(x+1)(x+5)=x2+6x+5
 
  :       ,      a     x1,x2,c     y1,y2,
 x1*y1+x2*y2==b  x1*y1+x2*y1==b,         ,     
     :  a*c    ,     a    *b    
#include<bits/stdc++.h>
using namespace std;

struct node{
    int x,y;
}line[110000];

int main(){
    int a,b,c,_;
    scanf("%d",&_);
    while(_--){
        scanf("%d%d%d",&a,&b,&c);
        int flag=0,cnt=0;
        for(int i=1;i<=sqrt(c)+1;i++){
            if(c%i==0){
                line[cnt].x=i;
                line[cnt++].y=c/i;
            }
        }
        for(int i=1;i<=sqrt(a)+1;i++){
            if(a%i==0){
                int x1=i,x2=a/i;
                for(int j=0;j<cnt;j++){
                    if(x1*line[j].x+x2*line[j].y==b||(x1*line[j].y+x2*line[j].x==b)){
                        flag=1;
                        break;
                    }
                }
            }
            if(flag==1)
                break;
        }
        if(flag==1)
            printf("YES
"); else printf("NO
"); } return 0; }

좋은 웹페이지 즐겨찾기