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 |
10分钟把代码搞定,结果竟然TLE,于是第一次打了表,结果还算TLE,哥郁闷了,回到原来代码,优化后终于AC了。Source Code Problem: 2262 User: sicojuy Memory: 156K Time: 235MS Language: C Result: Accepted Source Code #include <stdio.h> #include <math.h> int main() { long n, i, j, k, m; while(scanf("%ld", &n), n) { for(i = 3; i < 500000 ; i += 2) { m = sqrt(i) + 1; for(j = 3; j < m; j += 2) if(i % j == 0) break; if(j >= m) { k = n - i; m = sqrt(k) + 1; for(j = 3; j < m; j += 2) if(k % j == 0) break; if(j >= m) { printf("%ld = %ld + %ld\n", n, i, k); break; } } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator