1 10 1 20 3 30 4 0 0
Case 1: 2 Case 2: 4 Case 3: 5源代码:#include <stdio.h> #include <stdlib.h> int main() { int i,t,n,m,a,b; int num,count; scanf("%d",&t); for(i = 0;i < t;i++) { num = 0; while(scanf("%d%d",&n,&m) && (m!=0 || n!=0)) { num ++; 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",num,count); } if(i < t-1)//用于设置两个测试用例之间有一空行 printf("\n"); } system("pause"); return 0; }
原文地址:http://blog.csdn.net/zchlww/article/details/41352069