PersonalCorpus 版 (精华区)
39077 2002-10-06 02:54:05 Accepted
1312 C++ 00:00.01 380K Big Guava
int main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\uva\\input406.txt","r",stdin);
freopen("c:\\uva\\output406.txt","w",stdout);
#endif
int p[170];
int i,j,k,c,n,mark;
p[0]=1;p[1]=2; k=1; p[169]=1001;
for (i=3;i<1000;i++) {
mark=0;
for(j=1;j<=k;j++) if (i%p[j]==0) { mark=1; break; }
if (mark==0) { k++; p[k]=i; }
}
while (scanf("%d%d\n",&n,&c)==2) {
printf("%d %d:",n,c);
for (i=0;i<169;i++) if (p[i]>n) break;
if (i%2==0) {
for (j=i/2-c;j<i/2+c;j++) if ((j>=0)&&(j<i)) printf(" %d",
p[j]);
}else {
for (j=i/2-c+1;j<i/2+c;j++) if ((j>=0)&&(j<i)) printf("
%d",p[j]);
}
printf("\n\n");
}
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.336毫秒