After the number
http://acm.hdu.edu.cn/showproblem.php?pid=1406
Time limit:2000/1000 MS (java/others)
Memory limit:65536/32768 K (java/others)
Problem Description
The definition of a number: if the sum of all the factors of a positive integer greater than 1 equals its own, it is said that the number is the end of the number, such as 6, 28 is the end: 6=1+2+3;28=1+2+4+7+14. The task of the subject is to judge the number of the number of two positive integers.
Input
The input data contains multiple rows, the first row is a positive integer n, which indicates the number of test instances, then n test instances, one row for each instance, consisting of two positive integers num1 and num2 (1<num1,num2<10000).
This article URL address: http://www.bianceng.cn/Programming/sjjg/201410/45516.htm
Output
For each set of test data, output the number of NUM1 and num2 (including NUM1 and num2).
Sample Input
22 55 7
Sample Output
01
Note the interval endpoint problem.
Complete code:
/*0ms,208kb*/
#include <cstdio>
#include <algorithm>
using namespace std;
const int perfect_number[] = {6, 496, 8128};
int main ()
{
int T, a, B, I, J;
scanf ("%d", &t);
while (t--)
{
scanf ("%d%d", &a, &b);
if (a > B) Swap (A, b);
for (i = 0; i < 4; ++i)
if (a <= perfect_number[i]) break;
for (j = 0; j < 4; ++j)
if (b < perfect_number[j]) break;///Be careful!
printf ("%d\n", j-i);
}
return 0;
}