山东省第八届 ACM 省赛 quadratic equation (水、坑)

网友投稿 627 2022-10-03

山东省第八届 ACM 省赛 quadratic equation (水、坑)

山东省第八届 ACM 省赛 quadratic equation (水、坑)

Problem Description

With given integers a,b,c, you are asked to judge whether the following statement is true: “For any x, if a⋅x2+b⋅x2+c=0

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

题意

给出 ​​a,b,c​​​ ,判断 a⋅x2+b⋅x2+c=0 是否有非整数解,若有,输出 ​​NO​​​ ,否则输出 ​​YES​​ 。

思路

从测试数据可以看出如果原方程式无实数解时输出 ​​YES​​ 。

于是便是很多很多的 ​​if​​ 啦!

注意:这题有坑、这题有坑、这题有坑,如果 a,b,c 都是 0 的情况 x 可以取任意实数,所以输出 NO

如果没有这个坑,可能省赛的时候就是稳金了,忧伤~

AC 代码

#include#include#include#include#include#includeusing namespace std;#include#include#define eps (1e-8)bool jud(int a,int b,int c){ if(a==0) { if(b==0) { if(c==0)return false; // 已心痛的坑 return true; } else if(c%b==0)return true; return false; } double der=b*b-4*a*c; int s=(int)sqrt(der); if(der<0)return true; if(fabs(s-sqrt(der))

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:微信小程序如何进行异步处理(小程序异步解决方案)
下一篇:小程序怎么把富文本转换为文本
相关文章

 发表评论

暂时没有评论,来抢沙发吧~