题目链接
/*
Name:
Copyright:
Author:
Date: 2018/5/3 16:32:15
Description:
*/
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
bool equals(int a, int b) {
if ((a*a+b*b+m) % (a*b) == 0)return true;
return false;
}
int main()
{
int t;
cin>>t;
while (t--) {
int tag = 0;
while (cin>>n>>m) {
if ((n+m) == 0) break;
int ct = 0;
for (int i=1; i<n; i++) {
for (int j=i+1; j<n; j++) {
if (i == j) continue;
if (equals(i, j)) {
ct++;
}
}
}
printf("Case %d: %d
", ++tag, ct);
}
if (t >= 1) printf("
");//换行
}
return 0;
}