第八届ACM山东省赛 F quadratic equation
2017-05-18 23:27
288 查看
quadratic equation
Time Limit: 2000MSMemory Limit: 131072KB
Submit
Statistic
Problem Description
With given integers a,b,c, you are asked to judge whether the following statement is true: "For anyx, if a⋅
![](http://www.sdutacm.org/image/3898.png)
+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分析
3 1 4 4 0 0 1 1 3 1
Example Output
YES YES NO
Hint
Author
“浪潮杯”山东省第八届ACM大学生程序设计竞赛(感谢青岛科技大学)分析:会if就能做,条件判断入门题
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
if(a==0 && b==0 )
{
if(c==0)
{
puts("NO");
continue;
}
else
{
puts("YES");
continue;
}
}
else if(a==0 && b!=0)
{
if(c%b !=0)
{
puts("NO");
continue;
}
else
{
puts("YES");
continue;
}
}
else if(a!=0)
{
int dt=b*b-4*a*c;
if(dt<0)
{
puts("YES");
continue;
}
else
{
double kg=sqrt(dt);
if(((-b+kg)/(2*a)) - (int)((-b+kg)/(2*a))==0 && ((-b-kg)/(2*a))- (int)((-b-kg)/(2*a))==0 )
{
puts("YES");
continue;
}
else
{
puts("NO");
continue;
}
}
}
}
return 0;
}
相关文章推荐
- ACM 第八届山东省赛 F quadratic equation SDUT 3898
- 山东省第八届 ACM 省赛 quadratic equation (水、坑)
- “浪潮杯”山东省第八届ACM大学生程序设计竞赛F
- 山东省第八届 ACM 省赛 fireworks (组合数+逆元)
- 山东省第八届acm省赛C题 fireworks
- 山东省第八届ACM大赛I题题解
- 山东省第八届 ACM 省赛 sum of power (求和、水)
- 第八届acm山东省赛总结
- 山东省第八届ACM省赛 K 题 CF (排序01背包)
- “浪潮杯”山东省第八届ACM大学生程序设计竞赛I
- ”浪潮杯”山东省第八届ACM大学生程序设计竞赛 K CF【01背包 + 贪心】
- 第八届山东省ACM大学生程序设计竞赛总结
- 山东省第八届 ACM 省赛 G sum of power (简单快速幂)
- 山东省第八届ACM省赛 K 题(CF)
- “浪潮杯”山东省第八届ACM大学生程序设计竞赛 J
- 山东省第八届ACM省赛 G 题 sum of power 解答
- 2017年ACM第八届山东省赛K题:CF
- 山东省第八届acm省赛D题 HEX
- 山东省第八届ACM省赛 I 题 Parity check 详解
- 2017年山东省第八届ACM大学生程序设计竞赛总结