题目:http://acm.hdu.edu.cn/showproblem.php?pid=1017
#include <stdio.h> int main(){ int N,n,m,a,b,count=0,Case; scanf("%d", &N); while (N--) { int Case = 1; while (scanf("%d %d",&n,&m)!=EOF) { if (n == 0 && m == 0) { break; } if (0 > n || n > 100) { break; } for ( a = 1; a < n-1; a++) { for ( b = a+1; b < n; b++) { if ((a*a + b*b + m)%(a * b)== 0) { count++; } } } printf("Case %d: %d ", Case++, count); count = 0; } if (N > 0) printf(" "); } }
输出的显示:
2
10 1
Case 1: 2
20 3
Case 2: 4
30 4
Case 3: 5
0 0
10 1
Case 1: 2
20 3
Case 2: 4
30 4
Case 3: 5
0 0
注:题目感觉有点坑,上面明明有一个空行,结果按照样例输入结果就是不多