-
Notifications
You must be signed in to change notification settings - Fork 0
/
Zoj 1312 .txt
73 lines (53 loc) · 1.09 KB
/
Zoj 1312 .txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//------zoj1312
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
const int N =10005;
int dp[N];
void Buildprime(){ //С±ê´Ó1¿ªÊ¼
int a=4;
dp[1]=1;
dp[2]=2;
dp[3]=3;
for(int i=5; i<N; i++){
int j;
for(j=sqrt(i); j>1; j--){
if(!(i%j)){
break;
}
}
if(j==1)
dp[a++]=i;
}
}
int main(){
Buildprime();
int n,c;
int ans[N];
while(scanf("%d%d",&n,&c)!=EOF){
printf("%d %d:",n,c);
int a=1,t=0;
while(dp[a]<=n)
a++;
a--;
if(a%2){ //odd
int l=a/2-c+2;
int h=a/2+c;
if(h-l+1>=a) {l=1; h=a;}
for(int i=l; i<=h; i++)
printf(" %d",dp[i]);
}
else{ //even
int l=a/2-c+1;
int h=a/2+c;
if(h-l+1>=a) {l=1; h=a;}
for(int i=l; i<=h; i++)
printf(" %d",dp[i]);
}
printf("\n\n"); //×¢Òâ
}
return 0;
}