A Mathematical CuriosityTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total Submission (s): 25871 Accepted Submission (s): 8174
Problem Descriptiongiven-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 was an integer N and then a blank line followed by N input blocks. Each input block was 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.
Inputyou'll is given a number of cases in the input. Each case was specified by a line containing the integers n and M. The end of input is indicated by a case in which n = m = 0. Assume that 0 < n <= 100.
Outputfor, print the case number as well as the number of pairs (a, b) satisfying the given property. Print the output for each case is on one line in the format as shown below.
Sample Input
110 120 330) 40 0
Sample Output
Case 1:2case 2:4case 3:5
Sourceeast Central North America 1999, practice
recommendjgshining | We have carefully selected several similar problems for you:1013 1018 1005 1021 1012
Don't explain the problem. The example of the problem is wrong, the 1 after the no empty line, or see the discussion area to know.
Code: 78MS
#include <iostream>using namespaceStd; int Main () { int N,M,Cont=0,Num=0; int T;Cin>>T; while (T --) { while( Cin>>N>>M&&N!=0 ) { int A,B; for (A=1;A<=N;++A ) { for( B=A+1;B<N;++B ) { if( A*A+B*B+M)%(A*B)==0)Cont++; } }cout<<"Case"<<++Num<<": "<<Cont<<Endl;The students who did not hit the blanks couldn't afford to hurt themselves.。
。 Cont=0; num=0; if (T) cout<<Endl; } }
HDU 1017 A Mathematical Curiosity (mathematics)