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 |
Time Limit Exceed#include <stdio.h> int store[3513]={2,0}; int main() { int a[16385]={0},num,k=1,i,j,input=0; for(i=0;i<16385;i++) { if(a[i]) continue; store[k++]=2*i+3; for(j=i+1;j<16385;j++) if(!a[i]&&((2*j+3)%(2*i+3)==0)) a[j]=1; } while(scanf("%d",&input)==1&&input) { int answer=0; if(input==4) answer=1; else { for(i=1;store[i]<=input/2;i++) for(j=1;store[j]<=input;j++) { if(store[j]+store[i]==input) { answer++; break; } } } printf("%d\n",answer); } return 0; } 可是总是Time Limit Exceed,这题时间怎么那么快啊 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator