Cycle-23. Find out the number

Source: Internet
Author: User

Cycle-23. Find out (20) time limit MS Memory limit 65536 KB code length limit 8000 B award Program StandardAuthor Chen Jianhai (Zhejiang University) source Zoj

The so-called completion of the number is exactly equal to the sum of factors other than itself. For example: 6=1+2+3, where 1, 2, and 3 are 6 factors. The subject asks to write a program that finds all the ends of any two positive integers m and N.

Input format:

The input gives 2 positive integers m and n (0<m<=n<=10000) in one row, separated by a space.

Output format:

Progressive output decomposition of the cumulative form of the factor for each count in a given range, with one row for each end, with the format "finish = Factor 1 + Factor 2 + ... + factor k", where the completion and the factors are given in ascending order.

Input Sample:

1 30

Sample output:

1 = 16 = 1 + 2 + 328 = 1 + 2 + 4 + 7 + 14
1#include <stdio.h>2#include <math.h>3#include <stdlib.h>4#include <string.h>5 intMain ()6 {7     intN, M, I, J, sum;8scanf"%d%d", &n, &m);9     intflag[m+1];Tenflag[1] =1; One      for(i =2; I <= m+1; i++) AFlag[i] =0; -      for(i = n; i <= m; i++) -     { thesum =1; -          for(j =2; J <= sqrt (i); J + +) -         { -             if(I%j = =0) +sum = sum + j + I/J; -         } +         if(Sum = =i) AFlag[i] =1; at     } -      for(i = n; i <= m; i++) -     { -         if(Flag[i]) -         { -printf"%d = 1", i); in              for(j =2; J < I; J + +) -                 if(I%j = =0) toprintf"+%d", j); +printf"\ n"); -         } the     } *     return 0; $}

Cycle-23. Find out the number

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.