HDU 1406 Completion (number theory)

Source: Internet
Author: User
Tags integer first row time limit

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;  
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.