Untitled
unknown
plain_text
2 years ago
650 B
5
Indexable
//Bai 8
#include <iostream>
using namespace std;
typedef long long ll;
int p[10000001];
void sieve(){
for(int i = 0; i < 10000001; i++) p[i] = 1;
p[0] = p[1] = 0;
for(int i = 2; i <= 3162; i++){
if(p[i]){
for(int j = i*i; j <= 10000000; j+=i)
p[j] = 0;
}
}
}
int s_nt(int n){
while(n){
if(!p[n]) return 0;
n /= 10;
}
return 1;
}
int main(){
freopen("SPRIME.inp","r",stdin);
freopen("SPRIME.out","w",stdout);
sieve();
int a, b, cnt = 0; cin >> a >> b;
for(int i = a; i <= b; i++){
if(s_nt(i)){
cout << i << endl;
++cnt;
}
}
if(!cnt) cout << "NO" << endl;
return 0;
}Editor is loading...
Leave a Comment