HDU 1017 A Mathematical Curiosity
来源:互联网 发布:java接口与安卓对接 编辑:程序博客网 时间:2024/05/22 13:56
A Mathematical Curiosity
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31655 Accepted Submission(s): 10141
Problem Description
Given two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.
This problem contains multiple test cases!
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between output blocks.
Input
You will be given a number of cases in the input. Each case is specified by a line containing the integers n and m. The end of input is indicated by a case in which n = m = 0. You may assume that 0 < n <= 100.
Output
For each case, print the case number as well as the number of pairs (a,b) satisfying the given property. Print the output for each case on one line in the format as shown below.
Sample Input
1
10 1
20 3
30 4
0 0
Sample Output
Case 1: 2
Case 2: 4
Case 3: 5
题目大意,给你一个n和m,要使 (a^2+b^2 +m)/(ab) 的结果为整数,问你有多少种a,b的解
由于数据规模不打n最大100 直接暴搜,
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>using namespace std;int main(){ int x,m,n,flag=0; cin>>x; while(x--) { int vis = 1; while(cin>>n>>m,m||n) { int ans = 0; for(int i = 1;i < n; i++) for(int j = i+1; j<n; j++) if((i*i+j*j+m)%(i*j) == 0) ans++; printf("Case %d: %d\n",vis++,ans); } if(x > 0) cout<<endl; } return 0;}
- HDU 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- HDU 1017A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- HDU--1017--A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU:1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- hdu-1017-A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- hdu 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- HDU 1017 A Mathematical Curiosity
- 黑马程序员--java--多态和内部类
- hdu 多校
- SEL数据类型的简单知识点——和方法有关
- 实现简单HTTP服务器-图片与CGI
- IOS 值得注意的地方
- HDU 1017 A Mathematical Curiosity
- 从ValueType讨论c#的值类型系统
- openlayers3使用总结
- STL学习
- 定期iOS的后台位置更新-- 相关资料收集,待有时间进行整理
- Eclipse中c开发printf无法输出解决办法
- MSDN订阅用户可以下载Windows 10正式版啦
- 黑马程序员--java--异常
- uboot bootargs bootcmd bootm