BestCoder Round #70 Jam's math problem(hdu 5615)
Jam has a math problem. He just learned factorization. He is trying to factorize ax^2+bx+cax2+bx+c into the form of pqx^2+(qk+mp)x+km=(px+k)(qx+m)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.
The first line is a number TT, means there are T(1 \leq T \leq 100 )T(1≤T≤100) cases
Each case has one line,the line has 33 numbers a,b,c (1 \leq a,b,c \leq 100000000)a,b,c(1≤a,b,c≤100000000)
You should output the "YES" or "NO".
2
1 6 5
1 6 4
YES
NO
The first case turn x^2+6*x+5x2+6∗x+5 into (x+1)(x+5)(x+1)(x+5)
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD doublea
#define MAX 10100
#define mod 10007
using namespace std;
int ans[MAX];
int main()
{
int n,m,j,i,t,k;
int a,b,c,Min1,Min2;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&a,&b,&c);
Min1=min(a,10000);
Min2=min(c,10000);
k=1;n=m=1;
for(i=1;i<=Min2;i++)
{
n=c/i;
if(n*i==c)
ans[k++]=i;
}
int flag=0;
for(i=1;i<=Min1;i++)
{
m=a/i;
if(i*m==a)
{
for(j=1;j<k;j++)
{
if((i*ans[j]+m*(c/ans[j])==b)||(m*ans[j]+i*(c/ans[j])==b))
{
flag=1;
break;
}
}
}
if(flag)
break;
}
if(flag) printf("YES\n");
else printf("NO\n");
}
return 0;
}
BestCoder Round #70 Jam's math problem(hdu 5615)的更多相关文章
- BestCoder Round #29——A--GTY's math problem(快速幂(对数法))、B--GTY's birthday gift(矩阵快速幂)
GTY's math problem Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- BestCoder Round #67 (div.2) N bulbs(hdu 5600)
N bulbs Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Su ...
- Jam's math problem(思维)
Jam's math problem Submit Status Practice HDU 5615 Description Jam has a math problem. He just lea ...
- HDU 5055 Bob and math problem(结构体)
主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been think ...
- HDU 1757 A Simple Math Problem (矩阵乘法)
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- Little Sub and Mr.Potato's Math Problem (构造法)
题目传送门Little Sub and Mr.Potato's Math Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Littl ...
- 【2018 ICPC南京网络赛 A】An Olympian Math Problem(数论题)
Alice, a student of grade 6, is thinking about an Olympian Math problem, but she feels so despair th ...
- HDU - 5974 A Simple Math Problem (数论 GCD)
题目描述: Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least ...
- hdu 5615 Jam's math problem(十字相乘判定)
d. Jam有道数学题想向你请教一下,他刚刚学会因式分解比如说,x^2+6x+5=(x+1)(x+5) 就好像形如 ax^2+bx+c => pqx^2+(qk+mp)x+km=(px+k)(q ...
随机推荐
- 【转】Eclipse Java注释模板设置详解
Eclipse Java注释模板设置详解 设置注释模板的入口: Window->Preference->Java->Code Style->Code Template 然后 ...
- 1002: A+B for Input-Output Practice (II)
问题描述: http://acm.wust.edu.cn/problem.php?id=1002&soj=0 代码实现: import java.util.Scanner; public cl ...
- git push
使用git push直接推送未关联分支的时候,出现如下提示: $ git push Counting objects: 46, done. Delta compression using up to ...
- hdu4576 概率dp n^2的矩阵
这个题目看网上好多题解都是直接O(n*m)卡过.我是这么做的. 对于m次操作,统计每个w的次数.然后对每个w做矩阵乘法. 这样直接做矩阵乘法是会TLE的. 又由于这里的矩阵很特殊,一次乘法可以降维成O ...
- 对EditText监听,按钮点击
1 etBarCode.addTextChangedListener(watcher); 2 private TextWatcher watcher = new TextWatcher() { @Ov ...
- 图像、帧、片、NALU
图像.帧.片.NALU 是学习 H.264 的人常常感到困惑的一些概念,我在这里对自己的理解做一些阐述,欢迎大家讨论: H.264 是一次概念的革新,它打破常规,完全没有 I 帧.P帧.B 帧的概念, ...
- PNG文件结构分析 ---Png解析
PNG文件结构分析 ---Png解析 为了实现更高级的应用,我们必须充分挖掘PNG的潜力. PNG的文件结构 根据PNG文件的定义来说,其文件头位置总是由位固定的字节来描述的: 十进制数 13 ...
- poj 1236 Network of Schools
题目描述:有一些学校连接到一个计算机网络.这些学校之间达成了一个协议:每个学校维护着一个学校列表,它向学校列表中的学校发布软件.注意,如果学校B在学校A的列表中,则A不一定在B的列表中.任务A:计算为 ...
- Android精美的日历控件
网上看到的精美日历控件,谨以此文记录一下,用到的时候再来翻翻 源码地址 : http://download.csdn.net/detail/abc13939746593/7265459
- 【转】setTag()/getTag()
原文网址:http://www.cnblogs.com/topcoderliu/archive/2011/06/07/2074419.html View中的setTag(Onbect)表示给View添 ...