hdu 1128 Self Numbers

http://acm.hdu.edu.cn/showproblem.php?pid=1128

水题,哎,水题也贴一个吧。。。注意和可能会超过1000000.

View Code
 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 int hash[1000070]={0};
 4 int main()
 5 {
 6     int i,temp,sum;
 7 
 8     for(i=1;i<=1000000;i++)
 9     {
10           sum=i;
11           temp=i;
12           while(temp)
13           {
14             sum+=temp%10;
15             temp/=10;
16           }
17           hash[sum]=1;
18 
19     }
20     for(i=1;i<=1000000;i++)
21     {
22           if(hash[i]==0)
23           printf("%d\n",i);
24     }
25 }

 

posted on 2012-11-14 23:59  仁者无敌8勇者无惧  阅读(122)  评论(0编辑  收藏  举报

导航