56分,help!
查看原帖
56分,help!
1138325
MC_dream_tsr楼主2024/8/28 14:29
# include<bits/stdc++.h>
using namespace std;
bool primse(int n){
	if(n < 2) return 0;
	for(int i = 2; i * i <= n; i++)
	    if(n % i == 0) return 0;
	return 1;
}
bool hw(int x){
	int t =  x, n = 0;
	while(x > 0) {
		n = n * 10 + x % 10;
		x /= 10;
	}
	if(t == n) return 1;
	else return 0;
}
int main(){
	int a, b;
	cin >> a >> b;
	if(b > 9999999) b = 9999999;
	for(int i = a; i <= b; i += 2) {
		if(hw(i)){
			if(primse(i)) cout << i << endl;
		}
	}
	return 0;
}
2024/8/28 14:29
加载中...