HDU-5615(Jam's math problem)(方程求解)
来源:互联网 发布:万网主机如何解析域名 编辑:程序博客网 时间:2024/06/14 15:58
HDU-5615-Jam's math problem(方程求解)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 870 Accepted Submission(s): 415
Problem Description
Jam has a math problem. He just learned factorization.
He is trying to factorizeax2+bx+c into the form of pqx2+(qk+mp)x+km=(px+k)(qx+m) .
He could only solve the problem in which p,q,m,k are positive numbers.
Please help him determine whether the expression could be factorized with p,q,m,k being postive.
He is trying to factorize
He could only solve the problem in which p,q,m,k are positive numbers.
Please help him determine whether the expression could be factorized with p,q,m,k being postive.
Input
The first line is a number T , means there are T(1≤T≤100) cases
Each case has one line,the line has3 numbers a,b,c(1≤a,b,c≤100000000)
Each case has one line,the line has
Output
You should output the "YES" or "NO".
Sample Input
21 6 51 6 4
Sample Output
YESNOHintThe first case turn $x^2+6*x+5$ into $(x+1)(x+5)$感觉这道题有点坑,可能是我英语不太好吧, p,q,m,k are positive numbers。 p,q,m,k 不应该是正数吗?可是按正数处理,样例都不满足。最后看了别人的题解才知道,当作整数处理。一元二次方程的解:x1=(-b-sqrt(b*b-4*a*c))/(2*a)、x2=(-b+sqrt(b*b-4*a*c))/(2*a),刚开始面对这道题也不知道要如何求解,最后看了同学的题解恍然大悟,而且方法很简单。x1=(-1)*(k/p),x2=(-1)*(m/q).即:(-1)*(k/p)=(-b-sqrt(b*b-4*a*c))/(2*a)、(-1)*(m/q)=(-b+sqrt(b*b-4*a*c))/(2*a),因k、p、m、q是整数,(2*a)、-b也是整数,只要sqrt(b*b-4*a*c)为整数就满足,输出YES,否则输出NO.
/*2016.3.15*/
#include<stdio.h>#include<math.h>#include<algorithm>using namespace std;int main(){long long a,b,c,q,p,k,m,n,h;double j;scanf("%I64d",&n);while(n--){scanf("%I64d%I64d%I64d",&a,&b,&c);j=b*b-4*a*c;//m=b*b-4*a*c;if(j>=0){j=sqrt(j);//q=sqrt(m) h=(int)j;//强制类型转换 if(j-h)//if(q*q!=m) printf("NO\n");elseprintf("YES\n");}elseprintf("NO\n");}return 0; }
0 0
- HDU-5615(Jam's math problem)(方程求解)
- HDU 5615 Jam's math problem
- HDU 5615 Jam's math problem
- HDU 5615 Jam's math problem
- hdu 5615 Jam's math problem
- HDU-5615-Jam's math problem
- Hdu 5615 Jam's math problem【数学】
- hdu 5615 Jam's math problem
- HDU 5615:Jam's math problem【模拟】
- HDU 5615 Jam's math problem
- HDU 5615 Jam's math problem <数学>
- hdu 5615 (Jam's math problem)
- HDU Problem 5615 Jam's math problem 【十字交叉,暴力】
- 杭电hdu 5615 Jam's math problem【胡搞过】
- HDU 5615 Jam's math problem(模拟)
- HDU 5615 Jam's math problem(十字相乘判定)
- HDU:5615 Jam's math problem(暴力,数学)
- HDU 5615 Jam's math problem(水~)
- Android Listview相关
- 历届试题 分糖果 【模拟】
- DAX Calculate&SUMMARIZE 关键词的说明
- linux(ubuntu) java环境搭建
- android_内容观察者
- HDU-5615(Jam's math problem)(方程求解)
- 动态规划入门杭电1231
- 2016SDAU课程练习一1000
- Tomcat显示中文图片
- vsftpd.conf文件说明
- [Leetcode]Verify Preorder Serialization of a Binary Tree
- 第3周项目2—本月有几天?(switch语句)
- C++ vector多维数组初始化及清零
- 头文件中定义const全局变量应注意的问题