HDU 5615 Jam's math problem

题目:http://acm.hdu.edu.cn/showproblem.php?pid=5615

代码:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<iostream>

using namespace std;

int main(){
    int T;
    scanf("%d",&T);
    long long a,b,c,s;
    for(int i=1;i<=T;i++){
        scanf("%I64d%I64d%I64d",&a,&b,&c);
        long long s=b*b-4*a*c;
        double q=sqrt((s));
        int p=(int)(q);
        if(q-p==0) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

分析:

题目要求pqmk为正整数即,根号下b*b-4*a*c为正整数,两个根为负数,即b大于根号下b*b-4*a*c(恒成立)。

你可能感兴趣的:(HDU 5615 Jam's math problem)