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 |
我这代码哪里可以优化?#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