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 ...
随机推荐
- Interpolated Strings
https://msdn.microsoft.com/en-us/library/dn961160.aspx ; // Before C# 6.0 System.Console.WriteLine(S ...
- oracle 11g SQL Developer instead of isqlplus
Oracle11g的新工具SQL DEVELOPER,替代了 isqlplus 1.创建连接方式 2.SQL输入窗口 3.表的结构及其他信息查阅 4.SQL语句测试 5.创建表 6.用户授权 7.数据 ...
- 对github中项目进行更新
进入本地仓库文件夹,我的仓库名是tufujiegit,然后 进入 git clone 接着将先前记录下来的地址复制到后面,回车 将下载github中该仓库的所有文件及文件夹,包括.git文件夹在内 ...
- hdu 1243 反恐训练营(dp 最大公共子序列变形)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1243 d[i][j] 代表第i 个字符与第 j 个字符的最大的得分.,, 最大公共子序列变形 #inclu ...
- SyntaxHighlighter -- 代码高亮插件
SyntaxHighlighter 下载文件里面支持皮肤匹配. 地址:http://alexgorbatchev.com/SyntaxHighlighter/
- android学习笔记六
Android中Activity的Intent大全 Api Level 3: (SDK 1.5) android.intent.action.ALL_APPS android.intent.actio ...
- 云计算服务模型,第 3 部分: 软件即服务(PaaS)
英文原文:Cloud computing service models, Part 3: Software as a Service 软件即服务 (SaaS) 为商用软件提供基于网络的访问.您有可能已 ...
- 程序破解之 API HOOK技术 z
API HOOK,就是截获API调用的技术,在程序对一个API调用之前先执行你的函数,然后根据你的需要可以执行缺省的API调用或者进行其他处理,假设如果想截获一个进程对网络的访问,一般是几个socke ...
- linux命令——rm
rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除.对于链接文件,只是删除了链接,原有文件均保持不变. rm是一个危险的命令,使用的 ...
- 【C# C++】C#中调用msvcr100.dll中的_beginthreadex函数
msvcr100.dll是VS2010的C运行时库DLL, _beginthreadex开启子线程的函数就在这个DLL里面实现 unsigned long _beginthreadex( voi ...