A Mathematical Curiosity
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 26129 Accepted Submission(s): 8275
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.
1 10 1 20 3 30 4 0 0
Case 1: 2 Case 2: 4 Case 3: 5
#include<stdio.h>
int main()
{
int t,i,n,m,a,b;
int k,c=0;
while(scanf("%d",&t)!=EOF)
{
for(i=0;i<t;i++)
{
k=1;
while(scanf("%d%d",&n,&m)&&(m!=0||n!=0))
{
for(a=1;a<n-1;a++)
{
for(b=a+1;b<n;b++)
if((a*a+b*b+m)%(a*b)==0) c++;
}
printf("Case %d: %d\n",k++,c);
c=0;
}
if(i!=t-1)
printf("\n");
}
}
return 0;
}
/*1.如何计算a,b的对数