hdoj--5615--Jam's math problem(数学)(交叉相乘)
来源:互联网 发布:ajax如何获取json数据 编辑:程序博客网 时间:2024/06/06 00:24
Jam's math problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 861 Accepted Submission(s): 411
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
我记得以前应该是这么做的,找出二次项系数跟常数项个子所有因子,然后组合,看是否可以组合产生一次项系数,,,本来以为会超时的,但是水过了 - - ||
#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;int a[10000+10],b[10000+10];int main(){int t;scanf("%d",&t);while(t--){memset(a,0,sizeof(a));memset(b,0,sizeof(b));int A,B,C;scanf("%d%d%d",&A,&B,&C);int cnt1,cnt2;cnt1=cnt2=0;for(int i=1;i<=sqrt(A);i++)if(A%i==0)a[cnt1++]=i;for(int i=1;i<=sqrt(C);i++)if(C%i==0)b[cnt2++]=i;int f=false;for(int i=0;i<cnt1;i++){int p=a[i];int q=A/a[i];for(int j=0;j<cnt2;j++){int k=b[j];int m=C/b[j];if(m*p+q*k==B){f=true;break;}if(p*k+q*m==B){f=true;break;}}if(f) break;}if(f) printf("YES\n");else printf("NO\n");}return 0;}
0 0
- hdoj--5615--Jam's math problem(数学)(交叉相乘)
- hdoj Jam's math problem 5615 (数学十字相乘法)暴力
- HDOJ 5615-Jam's math problem【数学】
- hdoj 5615 Jam's math problem 【十字相乘】
- HDU 5615 Jam's math problem(十字相乘判定)
- hdoj 5615 Jam's math problem (数学-因式分解)
- HDU:5615 Jam's math problem(暴力,数学)
- HDOJ 5615 Jam's math problem
- Hdu 5615 Jam's math problem【数学】
- HDU 5615 Jam's math problem <数学>
- HDU Problem 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 (数学题枚举)
- Jam's math problem(HDU5615)
- HDU 5615 Jam's math problem(模拟)
- hd 5615 Jam's math problem(枚举)
- phpstorm小总结
- ft上线蛋疼问题
- nginx中的if嵌套
- 细说Angular ng-class
- mysql心得
- hdoj--5615--Jam's math problem(数学)(交叉相乘)
- 委托和协议
- 欢迎使用CSDN-markdown编辑器
- mysql心得
- Spring MVC之 请求
- Tomcat实现Session对象的持久化原理及配置方法介绍
- 顺序表
- mysql心得
- JavaScript事件绑定与删除