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 |
请玩POJ的高手看看,我的代码为什么TLE,而且感觉这个题有点问题啊有人说不可能出现猜想错误的情况,但是题目是说任意一个大于6的数都能分解成两个奇质数,15怎么分解成两个奇质数?那么猜想不就错误了?还有人贴AC的代码,我拿去验证后发现他的程序把15分解成3和12,感觉很奇怪。请大家看看我的代码是什么问题,谢谢了! #include <stdio.h> #include <math.h> int prime[1000001]; int main() { int i,j,k,m,b; for(i=2;i<1000001;i++) { k=sqrt(i); for(j=2;j<=k;j++) { if(i%j==0) break; } if(j>k) prime[i]=1; else prime[i]=0; } while(1) { scanf("%d",&m); if(m==0) break; for(i=3;i<=m/2;i++) { b=m-i; if(prime[i]==1&&prime[b]==1) { printf("%d=%d+%d\n",m,i,b); break; } } if(i>m/2) { printf("Goldbach's conjecture is wrong.\n"); } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator