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:tangwenwu at 2011-03-28 19:23:34 > #include<stdio.h> > int prime(int k){ > int flag=1; > int j; > for(j=2;j<=k/2;j++){ > if(k%j==0){ > flag=0; > break; > } > } > return flag; > } > int main(){ > int i,n,f=0; > for(scanf("%d",&n);n!=0;scanf("%d",&n)){ > for(i=3;i<=n/2;i=i+2){ > if(prime(i)&′(n-i)){ > printf("%d = %d + %d\n",n,i,n-i); > f=1; > break; > } > } > if(!f) > 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