Young2011 @ 2023-02-24 10:27:40
#include<bits/stdc++.h>
using namespace std;
bool ispn(int x){
if(x==1) return false;
for(int i=2;i*i<=x;i++){
if(x%i==0) return false;
}
return true;
}
bool hw(int k){
int a[10],i=0;
while (k>0){
a[i]=k%10;
k/=10;
i++;
}
for(int j=0;j<i;j++){
if(a[j]!=a[i-j-1]){
return false;
}
}
return true;
}
int main(){
long long n,m;
scanf("%d %d", &n, &m);
for(int i=n;i<=m;i++){
if(i==9989900)
break;
if(ispn(i) && hw(i)){
cout<<i<<endl;
}
}
return 0;
}
by olegekei @ 2023-02-24 11:41:59
@Young2011
if(ispn(i) && hw(i))
改为
if(hw(i) && ispn(i))
by Young2011 @ 2023-02-25 09:00:44
谢谢大佬