Hdoj 1406 HDU 1406 finished ACM 1406 in HDU

Source: Internet
Author: User
Miyu original, post Please note: Reprinted from __________ White House

Question address:
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1406
Description:Quantity

time limit: 2000 / 1000 MS (Java / others) memory limit: 65536 / 32768 K (Java / others)
total submission (s): 6817 accepted submission (s): 2131

Problem description
Definition of final number: if the sum of all the factors of a positive integer greater than 1 is equal to its own, it is called the final number. For example, 6 and 28 are all final numbers:6=1+2+3;28=1+2+4+7+14.

The task of this question is to determine the number of completion numbers between two positive integers.
 

Input
The input data contains multiple rows. The first row is a positive integer N, indicating the number of test instances. Then there are n test instances. Each instance occupies one row and consists of two positive integers num1 and num2, (1<Num1, num2<10000).
 

Output
For each group of test data, output the number of instances between num1 and num2 (including num1 and num2.
 

Sample Input
2
2 5
5 7
 

Sample output
0
1

Water problems, directly ignore;
Code As follows: # Include < Iostream >
# Include < Cmath >
Using   Namespace STD;
Int Judge ( Int A, Int B)
{
Int N =   0 ;
If ( > B)
A ^ = B ^ = A ^ = B;
If ( 6   > = A &&   6   <= B)
N ++ ;
If ( 28   > = A &&   28   <= B)
N ++ ;
If ( 496   > = A &&   496   <= B)
N ++ ;
If ( 8128   > = A &&   8128   <= B)
N ++ ;
Return N;
}
Int Main ()
{
Int T;
Scanf ( " % D " , & T );
{
While (T -- )
{
Int A, B;
Scanf ( " % D " , & A, & B );
Printf ( " % D \ n " , Judge (a, B ));
}
}
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.