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 |
提交n次了都wa,哪位高手来帮下小弟?郁闷啊!#include<stdio.h> int main() { int prime[500]={1,2,0},i,i1,i2,k,index=2,input1,input2; for(i=3;i<1500;i++) { k=0; for(i1=1;i1<index;i1++){if(i%prime[i1]==0){k++;break;}} if(!k){prime[index++]=i;} } while(scanf("%d %d",&input1,&input2)!=EOF) { for(i=0;prime[i]<input1;i++); if(prime[i]=input1)i++; if(i%2==0) { i1=(i/2)-input2; i2=(i/2)+input2-1; } else { i1=((i-1)/2)-input2+1; i2=((i-1)/2)+input2-1; } if(i1<0)i1=0; if(i2>=i)i2=i-1; printf("%d %d:",input1,input2); for(i=i1;i<=i2;i++){printf(" %d",prime[i]);} printf("\n\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