A Mathematical Curiosity

#include <iostream>
using namespace std;
int main()
{
 int n, m;//输入
 int r, a, b, c;
 int N;//情况
 cin>>N;
 for(int i=0;i<N;i++)
 {
     c = 0;
  while (cin>>n>>m)
  {
   if (n == 0 && m == 0)
    break;
   r = 0;
   for (a = 1; a < n; ++a)
   {
    for (b = 1; b <= n; ++b)
    {
        if(a>b)
     if ((a*a+b*b +m)%(a*b) == 0)
      ++r;
    }
   }
   cout<<"Case "<<++c<<": "<<r<<endl;
  }
  if(i!=N-1)
      cout<<endl;
 }
 return 0;
}

你可能感兴趣的:(A Mathematical Curiosity)