HDU1017 A Mathematical Curiosity

题目地址: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;
}

posted on 2008-01-04 19:03  Phinecos(洞庭散人)  阅读(1099)  评论(0编辑  收藏  举报

导航