ACM 第八届山东省赛 F quadratic equation SDUT 3898

来源:互联网 发布:知乎融资历程 编辑:程序博客网 时间:2024/06/03 17:08


再次提交链接: 点击打开链接


quadratic equation

Time Limit: 2000MS Memory Limit: 131072KB
Submit Statistic

Problem Description

With given integers a,b,c, you are asked to judge whether the following statement is true: "For any x, if a+bx+c=0, then x is an integer."

Input

The first line contains only one integer T(1≤T≤2000), which indicates the number of test cases.
For each test case, there is only one line containing three integers a,b,c(−5≤a,b,c≤5).

Output

or each test case, output “YES” if the statement is true, or “NO” if not.

Example Input

31 4 40 0 11 3 1

Example Output

YESYESNO

Hint

Author

“浪潮杯”山东省第八届ACM大学生程序设计竞赛(感谢青岛科技大学)

考察的是离散数学的蕴含式的理解   P-->Q     只有P为1 Q为0是 结果才是0  其余情况全为1  所以

当P为0 即P 不成立时 结果依然是YES  这是一个坑 



#include <iostream>#include <algorithm>#include <cmath>#include <stdio.h>#include <cstring>using namespace std;int main(){    int T;    cin>>T;    int a,b,c;    int cont=1;    while(T--)    {        cin>>a>>b>>c;        int flag;        if(a==0)        {            if(b!=0)            {                if(c==0)                    flag=1;                else if(c%b==0)                    flag=1;                else                    flag=0;            }            else            {                if(c==0)                    flag=0;                else                    flag=1;            }        }        else        {            int detal=b*b-4*a*c;            if(detal<0)                flag=1;            else            {                //printf("%d %lf\n",(int)sqrt(detal),sqrt(pow(sqrt(detal),2)));                if((int)sqrt(detal)==sqrt(pow(sqrt(detal),2)))                {                    if((-b+(int)sqrt(detal))%(2*a)==0&&(-b-(int)sqrt(detal))%(2*a)==0)                        flag=1;                    else                        flag=0;                }                else                    flag=0;            }        }        if(flag)            printf("YES\n");        else            printf("NO\n");    }    return 0;}



原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 注销电信卡话费怎么办 银行电话打不通怎么办 手机卡被注销了怎么办 手机卡号不知道怎么办 在手机上怎么办手机号 办手机卡被骗了怎么办 大王卡注销余额怎么办 注销大王卡话费怎么办 手机卡里还有话费怎么办 多余的话费要怎么办 联通流量欠费500怎么办 手机卡没了怎么办呢 联通显示无服务怎么办 大王卡停用了怎么办 手机卡中 剩余话费怎么办 小米被流量限制怎么办 支付宝禁止联网怎么办 手机号登录不上怎么办 电信手机号无法打电话怎么办 新手机号无法注册怎么办 电信手机怎么办流量包 qq华夏到监牢怎么办 炫舞被骗2900怎么办 qq好友申诉后怎么办 无好友辅助申请怎么办 辅助申诉成功后怎么办 qq绑不了手机号怎么办 新办号码有微信怎么办 两手机互换号后微信怎么办 手机申请不了qq怎么办 快手账号保护了怎么办 qq号过期登不上怎么办 xp 登陆界面不见了怎么办 手机号qq 别人登录怎么办 qq号申请频繁怎么办 qq号实名验证怎么办 陌陌没法注册怎么办 腾讯q币充值错误怎么办 手机号码注册微信号怎么办 q币充错了号怎么办 微信超额度提现都不可以怎么办