HDU Problem 5615 Jam's math problem 【十字交叉,暴力】
Jam's math problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1353 Accepted Submission(s): 610
Problem Description
Jam has a math problem. He just learned factorization.
He is trying to factorize ax2+bx+c into the form of x2+6∗x+5.
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.
He is trying to factorize ax2+bx+c into the form of x2+6∗x+5.
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 (x+1)(x+5),
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)
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
2
1 6 5
1 6 4
Sample Output
YES
NO
Hint
The first case turn into
Source
Recommend
copy
#include <map> #include <set> #include <cstdio> #include <cstring> #include <algorithm> #include <queue> #include <iostream> #include <stack> #include <cmath> #include <vector> #include <cstdlib> //#include <bits/stdc++.h> #define space " " using namespace std; //typedef long long LL; typedef __int64 Int; typedef pair<int,int> paii; const int INF = 0x3f3f3f3f; const double ESP = 1e-5; const double Pi = acos(-1); const int MOD = 1e9+5; const int MAXN = 1e5 + 10; Int a, b, c; int main() { int T; cin >> T; while (T--) { cin >> a >> b >> c; bool flag = false; if (b*b < 4*a*c) { cout << "NO" << endl; } else { Int sa = sqrt(a), sc = sqrt(c); for (int i = 1; i <= sa; i++) { if (a%i) continue; for (int j = 1; j <= sc; j++) { if (c%j == 0) { Int x = a/i, y = c/j; if ((i*j + x*y) == b || (i*y + j*x) == b) { flag = true; break; } } } if (flag) break; } if (flag) cout << "YES" <<endl; else cout << "NO" << endl; } } return 0; }
copy
本文作者: zprhhs
本文链接:https://www.cnblogs.com/cniwoq/p/6770806.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· 手把手教你在本地部署DeepSeek R1,搭建web-ui ,建议收藏!
· Spring AI + Ollama 实现 deepseek-r1 的API服务和调用
· 数据库服务器 SQL Server 版本升级公告
· 程序员常用高效实用工具推荐,办公效率提升利器!
· C#/.NET/.NET Core技术前沿周刊 | 第 23 期(2025年1.20-1.26)