Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
648 B
1
Indexable
Never
//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("test.inp","r",stdin);
	freopen("test.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;
}
Leave a Comment