Jam's math problem(思维)
Description







into the form of 



























. 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
, means there are 








cases Each case has one line,the line has
numbers 























Output
Sample Input
1 6 5
1 6 4
Sample Output
NO
Hint
The first case turn $x^2+6*x+5$ into $(x+1)(x+5)$
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<string>
using namespace std;
typedef long long LL;
/*
const int MAXN=1e5+100;
map<string,bool>mp;
char* tostring(LL x){
char s[12];
int tp=0;
while(x){
s[tp++]=x%10+'0';
x/=10;
}
s[tp]='\0';
reverse(s,s+tp);
return s;
}
void db(){
mp.clear();
for(int i=2;i<100000;i++){
if(!mp[tostring(i)])
for(LL j=(LL)i*i;j<=(LL)3000000000;j+=i){
mp[tostring(j)]=true;
}
}
}
int main(){
int T,a,b,c;
scanf("%d",&T);
db();
while(T--){
scanf("%d%d%d",&a,&b,&c);
if(a+b+c<4){
puts("NO");continue;
}
if(mp[tostring((LL)a+b+c)])puts("YES");
else puts("NO");
}
return 0;
}
*/
int main(){
LL a,b,c,p,q,m,k;
int T;
cin>>T;
while(T--){
cin>>a>>b>>c;
bool ans=false;
for(int p=;p*p<=a;p++){
if(a%p==){
q=a/p;
for(int k=;k*k<=c;k++){
if(c%k==){
m=c/k;
if(q*k+m*p==b||p*k+m*q==b)ans=true;
}
if(ans)break;
}
}
if(ans)break;
}
if(ans)puts("YES");
else puts("NO");
}
return ;
}
Jam's math problem(思维)的更多相关文章
- HDU 5615 Jam's math problem
Jam's math problem Problem Description Jam has a math problem. He just learned factorization.He is t ...
- BestCoder Round #70 Jam's math problem(hdu 5615)
Problem Description Jam has a math problem. He just learned factorization. He is trying to factorize ...
- 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 ...
- hdu 5615 Jam's math problem(判断是否能合并多项式)
方法一:由十字相乘相关理论我们能知道,如果要有p,k,q,m,那么首先要有解,所以b*b-4*a*c要>0,然而因为p,k,q,m是正整数,所以代表x1,x2都是有理数,有理数是什么鬼呢?就是解 ...
- hdu 1757 A Simple Math Problem (乘法矩阵)
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU1757 A Simple Math Problem 矩阵快速幂
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- hdu----(5055)Bob and math problem(贪心)
Bob and math problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- hdu------(1757)A Simple Math Problem(简单矩阵快速幂)
A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- FZYZ-2071 A Simple Math Problem IX
P2071 -- A Simple Math Problem IX 时间限制:1000MS 内存限制:262144KB 状态:Accepted 标签: 数学问题-博弈论 ...
随机推荐
- Word Ladder II 解答
Question Given two words (beginWord and endWord), and a dictionary's word list, find all shortest tr ...
- LeeCode-Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- 【斗地主技巧】斗地主算法逻辑中的天之道<转>
******************************************************************** 作者比较喜欢玩斗地主,所以经常搜集一些网友斗地主的心得,下面这 ...
- 回溯算法-C#语言解决八皇后问题的写法与优化
结合问题说方案,首先先说问题: 八皇后问题:在8X8格的国际象棋上摆放八个皇后,使其不能互相攻击,即任意两个皇后都不能处于同一行.同一列或同一斜线上,问有多少种摆法. 嗯,这个问题已经被使用各种语言解 ...
- ERROR: HHH000388: Unsuccessful: create table
做SSH整合的时候,总是出现错误信息: 类似这样: : HHH000388: Unsuccessful: create table right (right_code varchar(255) not ...
- CF 338 D GCD Table(CRT)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 给定一个序列,a[1 ..k],问是否存在(i , ...
- jQuery支持移动Mobile的DOM元素移动和缩放插件
jQuery Panzoom是一款很有用的HTML DOM元素平移和缩放jQuery和CSS3插件. Panzoom利用CSS transforms 和 matrix函数来为浏览器进行硬件(GPU)加 ...
- 一个操作EXCEL的C#类ExcelUtils
近期在公司里一直从事服务类的工作,涉及到非常多excel的处理.部分工作内容是每天反复的,仅仅是每天的数据不同而已.我遇到的一个问题是客户每天发送的几种数据有些excel中的字段顺序是一致的,有些是不 ...
- android——背景颜色渐变(梯度变化)
首先在drawable文件夹下面新建一个xml文件,起名为bgcolor.xml. 代码如下: <?xml version="1.0" encoding="utf- ...
- GIS-开发例程、源代码、MapXtreme、Map (转)
[原创]MapXtreme实用技巧与源码10例 普通图片生成MapInfo格式电子地图的步骤 http://blog.csdn.net/hmbb2008/category/184134.aspx 基 ...