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