Hduoj1017【水题】
来源:互联网 发布:阿里云建立二级域名 编辑:程序博客网 时间:2024/05/22 10:43
/*A Mathematical CuriosityTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31611 Accepted Submission(s): 10128Problem DescriptionGiven 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.InputYou 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.OutputFor 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 Input110 120 330 40 0Sample OutputCase 1: 2Case 2: 4Case 3: 5SourceEast Central North America 1999, Practice */#include<stdio.h>#include<string.h>int main(){int i, j, k, t, m, n;scanf("%d", &t);while(t--){int cas = 1;while( scanf("%d%d", &n, &m) != EOF && (n || m) ){k = 0;for(i = 1; i < n; ++i){for(j = i+1; j < n; ++j){if((i*i + j*j + m ) % (i*j) == 0)k++;}} printf("Case %d: %d\n", cas++, k);}if(t)printf("\n");}return 0;}
题意:给出n和m,求对数(a,b)要求(0<a<b<n),并且(a^2+b^2 +m)/(ab)为正数。输出对数。
思路:就是暴力。
0 0
- Hduoj1017【水题】
- 水题
- 水题
- 水题
- 水题
- 【水题】
- 水题
- 水题:
- 水题
- 水题~
- 水题
- 水题
- 水题
- 水题
- 水题
- 水题
- 【水题】
- 水题
- 设计模式六大原则
- refresh的停车场
- 2015 Multi-University Training Contest 1 /hdu 5289 Assignment -树状数组
- Cannot change version of project facet Dynamic Web Module to 2.5
- 单例模式
- Hduoj1017【水题】
- 动态规划-钢条切割《算法导论》
- 获取屏幕的大小
- EditText设置光标位置问题
- Java 集合 线程安全
- 跳表(SkipList)
- 如何借助加密软件预防企业内部泄密风险
- Vaadin——打开PDF文档
- java总结输入流输出流