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 |
WHY RA?#include "Stdio.h" main() { int i,j,number,flag,shift; int prime[200]; int N,C,all,start,s; prime[0]=1; prime[1]=2; number=2; for(i=3;i<1001;i++) { flag=1; for(j=1;j<=number;j++) { if(i%prime[j]==0) { flag=0; break; } } if(flag) {prime[number]=i; number++;} } while(scanf("%d%d",&N,&C)==2) { for(i=0;i<number;i++) { if(N<prime[i]) break; } all=i; if(all%2) s=2*C-1; else s=2*C; start=(i-s)/2; if(start<0) start=0; printf("%d %d:",N,C); shift=0; for(i=start;i<start+s;i++) { if((i>=number)||(prime[i]>N)) break; printf(" %d",prime[i]); shift++; if(shift==17) {shift=0;printf("\n\n");} } printf("\n\n"); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator