hdoj 5615 Jam's math problem (数学-因式分解)
来源:互联网 发布:苹果cms模板怎么用 编辑:程序博客网 时间:2024/05/21 10:15
Jam's math problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1348 Accepted Submission(s): 606
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
嗯,分解因式,数学学到的,最后遍历的时候b‘的值可能有两种情况,都要列出试探
#include<cstdio>#include<cmath>int main(){int t,a,b,c;scanf("%d",&t);while(t--){scanf("%d%d%d",&a,&b,&c);if(c<=0||a<=0){printf("NO\n");continue;}int m1=(int)sqrt(a*1.0);int m2=(int)sqrt(c*1.0);int b1,b2;//分解因式b'有两种情况,啊 int flag=0;for(int i=1;i<=m1;i++){if(a%i==0){for(int j=1;j<=m2;j++){if(c%j==0){b1=i*c/j+j*a/i;b2=i*j+a/i*c/j;if(b1==b||b2==b){flag=1;break;}}}}if(flag==1)break;}if(flag==1)printf("YES\n");elseprintf("NO\n"); } return 0; }
0 0
- 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【数学】
- HDU 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
- 设计模式-行为型- 策略模式(Strategy)
- Java并发编程:volatile关键字解析
- 排序算法之插入排序(模板类)
- "partition"和“stable_partition”的思考
- 10分钟快速了解Pandas
- hdoj 5615 Jam's math problem (数学-因式分解)
- 2、Java面向对象
- 广播的启动方式,以及优缺点
- C++函数后面加const修饰
- 设计模式之单例模式
- angularjs整合ueditor简介
- tinypy源码笔记(三)——虚拟机启动过程以及字节码分析
- Spring中的注解如何实现降低耦合度
- xilinx fpga学习笔记4