Sum of the HDU 1406 final number factor

Source: Internet
Author: User

 

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.

 

Today, this question is the same idea as that of yesterday. We use a method similar to filtering prime numbers to calculate the sum of factors.

 

# Include

 
  
Const int MAXN = 10000 + 2; const int N = MAXN> 1; int sum [MAXN] = {0}; int main () {for (int I = 2; I

  
   
B) {int temp = a; a = B; B = temp;} int cnt = 0; for (int I = a; I <= B; I ++) {if (sum [I] = i-1) // because my array is 0 at the beginning, and the factor contains 1cnt ++;} printf (% d, cnt );} 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.