标签:
简单水题,不用打表,算出1~10000的self number,运用数组下标即可。
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 21721 | Accepted: 12231 |
Description
Input
Output
Sample Input
Sample Output
1 3 5 7 9 20 31 42 53 64 | | <-- a lot more numbers | 9903 9914 9925 9927 9938 9949 9960 9971 9982 9993
Source
1 //oimonster 2 #include<cstdio> 3 #include<cstdlib> 4 #include<iostream> 5 using namespace std; 6 int a[20001]; 7 int count(int i){ 8 int p=i; 9 int s=i; 10 while(p>0){ 11 s=s+p%10; 12 p/=10; 13 } 14 return s; 15 } 16 int main(){ 17 int i,j,n; 18 for(i=1;i<=20000;i++)a[i]=0; 19 for(i=1;i<=10000;i++){ 20 a[count(i)]=1; 21 } 22 for(i=1;i<=10000;i++){ 23 if(a[i]==0)printf("%d\n",i); 24 } 25 return 0; 26 }
标签:
原文地址:http://www.cnblogs.com/oimonster/p/4292318.html