http://acm.hdu.edu.cn/showproblem.php?pid=1017
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
//freopen("in.txt","r",stdin);
int t;
scanf("%d",&t);
while(t--)
{
int Case=;
int n,m;
while()
{
cin>>n>>m;
int count=;
if(!n&&!m)
break;
for(int a=;a<n;a++)
{
for(int b=a+;b<n;b++)
{
if((a*a+b*b+m)%(a*b)==)
count++;
}
}
printf("Case %d: %d\n",Case++,count);
}
if(t!=)
printf("\n");
}
return ;
}