Jam's math problem

Problem Description
Jam has a math problem. He just learned factorization.
He is trying to factorize ax^2+bx+c into the form of 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 T, means there are T(1 <=T <=100 ) cases

Each case has one line,the line has 3 numbers a,b,c (1 <= a,b,c <=100000000)

 
Output
You should output the "YES" or "NO".
 
Sample Input
1 6 5
1 6 4
 
Sample Output
YES
NO

Hint

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

 
Recommend
hujie
题目大意:输入abc,问ax*x+bx+c=0能否因式分解
思路:只要判断qk+mp与b是否相等(a==pq,c==km)
注意:循环q可以用p==a/q,用i*i<=a可以防止重复的情况。。。
#include <stdio.h>
int main()
{
int a, b, c, i, j, T, flag;
scanf("%d", &T);
while(T--)
{
flag=;
scanf("%d%d%d", &a, &b, &c);
for(i=;flag&&i*i<=a;i++)
{
if(a%i==)
for(j=;flag&&j*j<=c;j++)
if(c%j==)
if(i*j+(a/i)*(c/j)==b||i*(c/j)+j*(a/i)==b)
flag=;
}
if(!flag) printf("YES\n");
else printf("NO\n");
}
return ;
}
 

HDU 5615 Jam's math problem的更多相关文章

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

  2. hdu 5615 Jam's math problem(判断是否能合并多项式)

    方法一:由十字相乘相关理论我们能知道,如果要有p,k,q,m,那么首先要有解,所以b*b-4*a*c要>0,然而因为p,k,q,m是正整数,所以代表x1,x2都是有理数,有理数是什么鬼呢?就是解 ...

  3. Jam's math problem(思维)

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

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

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

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

  6. HDU 1757 A Simple Math Problem 【矩阵经典7 构造矩阵递推式】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=1757 A Simple Math Problem Time Limit: 3000/1000 MS (J ...

  7. hdu 1757 A Simple Math Problem (乘法矩阵)

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

  8. HDU 1757 A Simple Math Problem (矩阵快速幂)

    题目 A Simple Math Problem 解析 矩阵快速幂模板题 构造矩阵 \[\begin{bmatrix}a_0&a_1&a_2&a_3&a_4&a ...

  9. HDU 1757 A Simple Math Problem(矩阵)

    A Simple Math Problem [题目链接]A Simple Math Problem [题目类型]矩阵快速幂 &题解: 这是一个模板题,也算是入门了吧. 推荐一个博客:点这里 跟 ...

随机推荐

  1. ThinkPHP 中实现 Rewrite 模式

    ThinkPHP中默认的URL地址是形如这样的:http://localhost/Myapp/index.php/Index/index/ Myapp是我的项目文件名,默认的访问地址是上面这样的.为了 ...

  2. 夺命雷公狗ThinkPHP项目之----企业网站5之栏目的添加(主要是图片上传)

    我们照老,先老搞定控CategoryController.class.php制器,代码如下所示: <?php namespace Admin\Controller; use Think\Cont ...

  3. LDA-math-认识Beta/Dirichlet分布

    http://cos.name/2013/01/lda-math-beta-dirichlet/#more-6953 2. 认识Beta/Dirichlet分布2.1 魔鬼的游戏—认识Beta 分布 ...

  4. 手机端js模拟长按事件(代码仿照jQuery)

    代码编写: $.fn.longPress = function(fn) { var timeout = undefined; var $this = this; for(var i = 0;i< ...

  5. centos的用户管理相关命令所在的包

    用户管理命令是指:useradd userdel  groupadd groupdel 这些 这些命令出自一个叫 shadow-utils 的包. 对于配置文件 /etc/shadow ,则来自一个叫 ...

  6. knockout之入门介绍

    Knockout是一个轻量级的UI类库,通过应用MVVM模式使JavaScript的前端UI简单化.Knockout是一个以数据模型(data model)为基础的能够帮助你创建丰富文本,响应显示和编 ...

  7. linux_c学习笔记之curl的使用一

    参考文档 使用libcurl发送PUT请求上传数据以及DELETE请求删除数据 http://blog.163.com/lixiangqiu_9202/blog/static/535750372014 ...

  8. ubuntu apache开启重写模块

    http://www.iblue.cc/2011/09/ubuntu-apache%E5%BC%80%E5%90%AF%E9%87%8D%E5%86%99%E6%A8%A1%E5%9D%97/ Ubu ...

  9. 如何获取各大平台的播放地址(获得优酷的m3u8播放地址)为例

    1.打开safari 2.在顶部(黑色小苹果)旁边,点击safari. 3.打开里面的 偏好设置. 4.在高级 中 找到 “在菜单栏中显示开发菜单” 并打勾. 5.关闭窗口后,可以发现safari 顶 ...

  10. Ecshop后台订单列表增加”商品名”检索字段

    近期ecshop网站做活动,统计商品订单量的时候没有按商品名搜索的选项,只能手动查询.这样效率很低下,而且容易出错. 现在为列表增加一个简单的“按商品名搜索”表单项.效果如下图 涉及到2个文件,分别是 ...