题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1017
简单题,就是注意下输出格式就ok,
#include<iostream>
#include<cmath>
using namespace std;
int doProcess(int n,int m)
{
int temp,count=0;
for (int a=1;a<n-1;++a)
{
for (int b=a+1;b<n;++b)
{
temp = a*a+b*b+m;
if (temp%(a*b)==0)
{
count++;
}
}
}
return count;
}
int main()
{
int caseNum,n,m,inerCase;
while (cin>>caseNum)
{
for (int i=0;i<caseNum;++i)
{
inerCase = 1;
while (cin>>n>>m&&!(n==0&&m==0))
{
cout<<"Case "<<inerCase<<": "<<doProcess(n,m)<<endl;
inerCase++;
}
if (i!=caseNum-1)
{
cout<<endl;
}
}
}
return 0;
}
本文转自Phinecos(洞庭散人)博客园博客,原文链接:http://www.cnblogs.com/phinecos/archive/2008/01/04/1026315.html,如需转载请自行联系原作者