Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我不想打表……可是这程序至少要5秒…… #include <stdio.h> int fun1(int n) { int s=n; while(n>0) { s+=n%10; n/=10; } return s; } int fun2(int n) { int i; for(i=1;i<=n;i++) if(n==fun1(i)) return 0; return 1; } int main() { int i; for(i=1;i<=9994;i++) if(fun2(i)) printf("%d\n",i); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator