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⋅+b⋅x+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;}
阅读全文
0 0
- ACM 第八届山东省赛 F quadratic equation SDUT 3898
- 第八届ACM山东省赛 F quadratic equation
- 山东省第八届ACM省赛 F 题(quadratic equation)
- 山东省第八届ACM省赛F.quadratic equation
- 山东省第八届 ACM 省赛 quadratic equation
- 山东省第八届ACM省赛 F题 quadratic equation (详解)
- 山东省第八届 ACM 省赛 quadratic equation (水、坑)
- 山东省第八届acm大赛 F题 (SDUT 3898)
- 山东第八届acm大赛F题quadratic equation,山东理工oj 3898
- quadratic equation 17年省赛F题,SDUT 3898
- ACM 第八届山东省赛 J company SDUT 3902
- ACM 第八届山东省赛 I Parity check SDUT 3901
- 端午节月赛-山东省第八届省赛 quadratic equation(多种情况,△的判断)
- 山东省第一届ACM省赛 F SDUT 2156 Fairy tale
- 山东省第八届acm大赛 J题 (SDUT 3902)
- 山东省第八届acm大赛 G题 (SDUT 3899)
- 山东省第八届acm大赛 I题 (SDUT 3901)
- “浪潮杯”山东省第八届ACM大学生程序设计竞赛F
- Java学习笔记之线程
- linux uniq去重
- DOM-1 基础
- svn入门
- 今天做到一道面试题:Handler+Looper+MessageQueue+Message的关系
- ACM 第八届山东省赛 F quadratic equation SDUT 3898
- Cookie/Session机制详解
- android 触摸事件的处理与总结
- JavaScript 面向对象思想以及原型、继承
- 求pai的近似值
- oracle 游标细节引发的错误
- 勘探油田
- xtu-1269 Similar Subsequence(dp+树状数组)
- RCNN, Fast-RCNN, Faster-RCNN