HDOJ 5615-Jam's math problem【数学】
来源:互联网 发布:优站目录源码 编辑:程序博客网 时间:2024/06/09 17:25
Jam's math problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 196 Accepted Submission(s): 102
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)$
Source
BestCoder Round #70
解题思路:
题目大意就是给出二元一次函数式的a,b,c问该式子能否被因式分解,初中学的十字交叉法,暴力就行了。
#include<stdio.h>#include<string.h>#include<cmath>#include<algorithm>#define LL __int64using namespace std;int main(){ int T; scanf("%d",&T); while(T--) { bool wc=false; LL a,b,c; scanf("%I64d%I64d%I64d",&a,&b,&c); if((b*b-4*a*c)<0) { printf("NO\n"); } else { LL i,j; for(i=1;i<=sqrt(a);i++) { for(j=1;j<=sqrt(c);j++) { if(a%i==0&&c%j==0) { LL xx,yy,uu,ii; xx=i,yy=a/i,uu=j,ii=c/j; if((xx*ii+yy*uu)==b||(xx*uu+yy*ii)==b) { wc=true; break; } } } if(wc==true) break; } if(wc==true) printf("YES\n"); else printf("NO\n"); } } return 0;}
0 0
- HDOJ 5615-Jam's math problem【数学】
- hdoj 5615 Jam's math problem (数学-因式分解)
- HDOJ 5615 Jam's math problem
- Hdu 5615 Jam's math problem【数学】
- HDU 5615 Jam's math problem <数学>
- hdoj 5615 Jam's math problem【数学】【判断方程能否因式分解】
- hdoj Jam's math problem 5615 (数学十字相乘法)暴力
- hdoj--5615--Jam's math problem(数学)(交叉相乘)
- hdoj 5615 Jam's math problem 【求根式】
- HDOJ 5615 Jam's math problem (数学题枚举)
- hdoj 5615 Jam's math problem 【十字相乘】
- HDOJ 5615 Jam's math problem (数学题枚举)
- HDU:5615 Jam's math problem(暴力,数学)
- Jam's math problem
- Jam's math problem
- HDU 5615 Jam's math problem
- HDU 5615 Jam's math problem
- HDU 5615 Jam's math problem
- 昨日参加hackerrank一比赛总结
- 年初英语
- HDU2896.病毒侵袭中【MLE和PE的原因】【AC自动机模板题】
- Redis源码解析:05跳跃表
- Django-blog-zinnia初体验(一)
- HDOJ 5615-Jam's math problem【数学】
- 一起talk C栗子吧(第一百一十五回:C语言实例--线程同步之互斥量一)
- Oracle单节点开启关闭归档日志
- 2016太原网络营销师郭文军分享网站中如何合理布局关键词?
- ios-提升之【1】-UIApplication
- HDOJ 5616-Jam's balance【模拟】
- RadioGroup方法总结
- Eclipse下通过Maven的Jetty插件运行Web工程的配置
- 2015杂谈