杭电oj1017

个人觉得这个看懂题目就不是很难,但是我看懂题目就很难。。

Given two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a^2+b^2 +m)/(ab) is an integer.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

意思是,给两个整数n,m,计算(a,b)数对的个数,这个a,b数对的存在有三个条件,0到n之间,且b>a,以及(a^2+b^2 +m)/(ab)是个整数

然后要首先输入一个n,这个n代表输入几块,这个块不是代表输入多少组数据,而是有多块,每块里面存在多组数据,输入0 0数对表示这个块结束了

重要的是,这个输出格式!!它说的n之后接一个空行不是输出一个空行,是输入的,然后每块之间有空行(意味着如果是最后一行,是不会后接空行的,杭电oj好多这种隐藏的输出格式说明)

Input

You will be given a number of cases in the input. Each case is specified by a line containing the integers n and m. The end of input is indicated by a case in which n = m = 0. You may assume that 0 < n <= 100.

 

 

Output

For each case, print the case number as well as the number of pairs (a,b) satisfying the given property. Print the output for each case on one line in the format as shown below.

 

 

Sample Input

 

1 10 1 20 3 30 4 0 0

#include 
using namespace std;
int main()
{
    int n;
    cin>>n;
    //cout<>a>>b)
        {
            m=0;
            num++;
            if((a+b)==0)
            {
                break;
            }
            for(int x=1;xx
                {
                    if((x*x+y*y+b)%(x*y)==0)
                    {
                        m++;
                    }
                }
            }
            cout<<"Case "<

 

你可能感兴趣的:(杭电oj1017)