Problem Description

Jam has a math problem. He just learned factorization. He is trying to factorize ax^2+bx+cax​2​​+bx+c into the form of pqx^2+(qk+mp)x+km=(px+k)(qx+m)pqx​2​​+(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.

Input

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)

Output

You should output the "YES" or "NO".

Sample Input
2
1 6 5
1 6 4
Sample Output
Copy

YES
NO
Hint

The first case turn x^2+6*x+5x​2​​+6∗x+5 into (x+1)(x+5)(x+1)(x+5)

 
题意:给你一个一元二次方程的三个系数a ,b,c问你是否能用十字相乘的方法分解这个式子
题解:直接暴力枚举,当然要优化下枚举的方法,不然会超时滴,优化:因为最大数据是一亿,一亿可以分解为一万乘一万,因为这样我们分解的两个数一定不可能超过一万,我们通过遍历让c除以1  2  3.....n来枚举c的因子,当超过10000时,新出现的因子我们已经枚举过了先将c的所有因子存在数组中,然后在计算出a的所有因子,一个一个试即可
#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)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Jam's math problem(思维)

    Jam's math problem Submit Status Practice HDU 5615   Description Jam has a math problem. He just lea ...

  4. HDU 5055 Bob and math problem(结构体)

    主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=5055 Problem Description Recently, Bob has been think ...

  5. HDU 1757 A Simple Math Problem (矩阵乘法)

    A Simple Math Problem Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Ot ...

  6. 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 ...

  7. 【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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. trackr: An AngularJS app with a Java 8 backend – Part III

    这是最后我们对trackr系列的一部分.在过去的两的博文中,我们已经向您展示我们使用的工具和框架构建后端和前端.如果你错过了前面的帖子现在你可能会想读他们赶上来. Part I – The Backe ...

  2. UVa 1025 (动态规划) A Spy in the Metro

    题意: 有线性的n个车站,从左到右编号分别为1~n.有M1辆车从第一站开始向右开,有M2辆车从第二站开始向左开.在0时刻主人公从第1站出发,要在T时刻回见车站n 的一个间谍(忽略主人公的换乘时间).输 ...

  3. 省常中模拟 Test1 Day1

    临洮巨人 排序 题意:在字符串中找出 A.B.C 三个字母出现次数相同的区间个数. 初步的解法是前缀和,用 a(i), b(i), c(i) 表示在位置 i 之前(包括 i)各有 字母 A.B.C 多 ...

  4. 《C++ Primer 4th》读书笔记 第5章-表达式

    原创文章,转载请注明出处: http://www.cnblogs.com/DayByDay/p/3912114.html

  5. Android 实现emoji表情的demo

    Android 实现emoji表情的例子,网上看到的,记录一下. 请看下图 : 项目下载地址:http://download.csdn.net/detail/abc13939746593/741397 ...

  6. RMAN 备份详解

    一.数据库备份与RMAN备份的概念 1.数据库完全备份:按归档模式分为归档和非归档 归档模式 打开状态,属于非一致性备份        关闭状态,可以分为一致性和非一致性 非归档模式 打开状态,非一致 ...

  7. POJ 2549 Sumsets

    Sumsets Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10593   Accepted: 2890 Descript ...

  8. HDU5715 XOR 游戏 二分+字典树+dp

    当时Astar复赛的时候只做出1题,赛后补题(很长时间后才补,懒真是要命),发现这是第二简单的 分析: 这个题,可以每次二分区间的最小异或和 进行check的时候用dp进行判断,dp[i][j]代表前 ...

  9. Android-day02_广播

    1.什么是广播 貌似一个人大声喊一句话,别人听到了这就是广播 2.在android中广播有标准广播和有序广播 标准广播也就是发送一个广播,所有人都能同一时间接收到 有序广播则是有顺序的广播,发送的时候 ...

  10. ckeditor+jsp+spring配置图片上传

    CKEditor用于富文本输入是极好的,它还有一些插件支持扩展功能,其中图片上传就是比较常用到的.本文简单记录我的实现步骤. 1.CKEditor除了提供三种标准版压缩包下载,还可根据自己的需求进行个 ...