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 |
Re:我这代码哪里可以优化?In Reply To:我这代码哪里可以优化? Posted by:haipeng31 at 2010-11-14 20:01:26 > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > > int digitsum(int num) > { > int sum = 0; > while(num != 0) { > sum += num % 10; > num = num / 10; > } > return sum; > } > > int main() > { > char selfstates[1000101]; > int i, j; > int sum; > for(i = 0; i < 1000001; i++) > { > selfstates[i] = 0; > } > > for(i = 0; i <= 999990; i += 10) > { > sum = i + digitsum(i); > for(j = 0; j < 10; j++) { > selfstates[sum+2*j] = 1; > } > } > > for(i = 1; i <= 1000000; i++) > { > if(selfstates[i] == 0) { > 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