-
Title Description:
-
For 1-n, the so-called end number is such a number, all its factors add equal to its own, such as 6 has 3 factors 1,2,3,1+2+3=6, then 6 is the end of the number. That is, the end number is equal to the sum of all its factors.
-
Input:
-
There are several groups of test data, and the input N,n data range is small.
-
Output:
-
For each set of inputs, output all of the 1-n in the list. If there is a case output has multiple numbers, separated by a space, the output finally do not have extra space.
-
Sample input:
-
6
-
Sample output:
-
6
-
Source:
-
-
-
Answering:
Problem solving problems? to discuss the subject of discussion please visit: http://t.jobdu.com/thread-7774-1-1.html
#include <iostream>using namespace Std;int main () {int m,j,i,a[1000],kk; while (cin>>m) { kk=0; for (j=1;j<=m;j++) { int k=0; for (i=1;i<j;i++) { if ((j%i) ==0) k=k+i; } if (k==j) a[kk++]=j; } for (i=0;i<kk;i++) { if (i!=0) cout<< ""; cout<<a[i]; } cout<<endl; } return 0;} /************************************************************** problem:1050 user:vhreal language:c++ result:accepted time:230 ms memory:1520 kb****************************************** **********************/
Nine degrees oj-topic 1050: Finish number