-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1990.cpp
More file actions
56 lines (56 loc) · 1.22 KB
/
1990.cpp
File metadata and controls
56 lines (56 loc) · 1.22 KB
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
#include <bits/stdc++.h>
using namespace std;
string pre, post;
vector<int> pel[9];
vector<int> prime;
int isErased[10001];
bool f(int x){
bool ret=true;
for(int i=0; prime[i]*prime[i]<=x; i++){
if(x%prime[i]==0){
ret = false;
break;
}
}
return ret;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
for(int i=2; i<10001; ++i){
if(!isErased[i]){
prime.push_back(i);
for(int j=i*i; j<10001; j+=i){
isErased[j]=1;
}
}
}
int a, b; cin>>a>>b;
for(int i=0; i<10; ++i){
pel[1].push_back(i);
pel[2].push_back(i*11);
}
int offset=100;
for(int i=3; i<9; ++i){
for(auto it:pel[i-2]){
for(int j=0; j<10; ++j){
pel[i].push_back(it*10+(offset+1)*j);
}
}
offset*=10;
}
offset=1;
vector<int> res;
for(int i=1; i<9; ++i){
for(auto it:pel[i]){
if(it<offset) continue;
if(it<a || it>b) continue;
if(f(it)) res.push_back(it);
}
offset *= 10;
}
sort(res.begin(), res.end());
for(auto it:res){
cout << it << '\n';
}
cout << "-1\n";
}