Problem Description
Given two integers n and m, count the number of pairs of integers (a,b) such that 0 < a < b < n and (a2+b2 +m)/(ab) is an integer.//要求a<b!!这个刚开始忽略了//而且满足式子为整数,a/b为整数 也就是a%b为0
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.//每输入一个N都要再输入一个空行,而且是测试样例是块,一组一组的 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.
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
Sample Output
Case 1: 2
Case 2: 4
Case 3: 5
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int N,n,m;
cin>>N;
while(N--){
int t=0;//统计样例
while(cin>>n>>m){
if(n==0&&m==0)
break;
int count=0;
t++;
for(int j=1;j<n;j++){
for(int i=(j+1);i<n;i++){
if((i*i+j*j+m)%(i*j)==0)
count++;
}
}
cout<<"Case "<<t<<": "<<count<<endl;/*Case 首字母大写!!检查了好几遍原来错误在这*/
}//while(cin>>n>>m)
if(N!=0&&n!=1)//别忘了只有一个测试块的时候
cout<<endl;
}
return 0;
}