//2014.10.17 01:19
//题意:
//先输入一个数N,然后分块输入,每块输入每次2个数,n,m,直到n,m同一时候为零时
//结束,当a和b满足题目要求时那么这对a和b就是一组
//注意:
//每一块的输出中间有一个回车
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.
110 120 330 40 0
Case 1: 2Case 2: 4Case 3: 5
#include<stdio.h>int main(){ int N; int n,m; int a,b; int cas; scanf("%d",&N); while(N--) { cas=1; while(scanf("%d%d",&n,&m),n||m) { int count=0; for(a = 1; a < n; a++)//穷举法 { for(b = a + 1; b < n; b++) { if((a*a + b*b + m) % (a * b) == 0) count++; } } printf("Case %d: %d\n",cas++,count); } if(N) printf("\n"); } return 0;}