编程介的小学生 2019-12-27 21:38 采纳率: 20.5%
浏览 72

Johnny and the Quadratic Equation 的设计的程序

Problem Description
Johnny recently learned about this whole quadratic equation thing. Being an avid young programmer,he immediately wrote the following code that was supposed to help in his homework:
#include
int main() {
unsigned int a,b,c,x=0;
scanf("%u %u %u",&a,&b,&c);
do {
if (a*x*x+b*x+c==0) {
puts("YES");
return 0;
}
x++;
} while(x);
puts("NO");
return 0;
}
where all calculations are performed on unsigned 32-bit integers (in other words, modulo 232). But,well, it turned out that this code runs rather slow, even on his recently updated monster gaming rig.Maybe you could help him?

Input
The input contains several test cases. The rst line contains an integer t (t <=104) denoting the number of test cases. Then t tests follow, each of them consisting of three space separated integers a, b and c (0 <= a, b, c < 232).

Output
For each test case output the answer of the program above.

Sample Input
3
948 43958 1429912782
95348 54988 345335
943428 4353958 3444096692

Sample Output
YES
NO
YES

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog