杭电1017 A Mathematical Curiosity

/********************************
 *    日期:2011-2-9
 *    作者:SJF
 *    题号:杭电1017
 *  题目:A Mathematical Curiosity
 *    结果:AC
 ********************************/
#include<stdio.h>
int main()
{
    int N;
    while(scanf("%d",&N)!=EOF)
    {
        int i,j,n,m,k;
        for(k=0;k<N;k++)
        {
            if(k>0)
            {
                printf("\n");
            }
            int casenum=0;
            while(scanf("%d%d",&n,&m)!=EOF)
            {
                int count=0;
                if((n==0)&&(m==0))
                {
                    break;
                }
                for(i=1;i<n;i++)
                {
                    for(j=1;j<i;j++)
                    {
                        if((i*i+j*j+m)%(i*j)==0)
                        {
                            count++;
                        }
                    }
                }
                casenum++;
                printf("Case %d: ",casenum);
                printf("%d\n",count);
            }
        }
    }
    return 0;
}
posted @ 2011-10-22 19:48  爱生活,爱编程  阅读(202)  评论(0编辑  收藏  举报