jizeen @ 2023-05-18 15:07:08
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,n,k;
int m[10];
cin >>a>>b;
if(a==2)cout<<2<<endl;
for (int i=a;i<=b;i++){
if(i%2==0) continue;
n=i;
bool o=0,s=0;
for(int j=1;n!=0;j++){
m[j]=n%10;
n=n/10;
k=j;
}
for(int l=1;l<=k/2;l++){
if(m[l]!=m[k+1-l])
{
o=1;break;}
}
if(o==0){
for(int p=3;p<=i/2;p+=2)
if(i%2==0||i%p==0){
s=1;
break; }
if(s==0)
cout<<i<<endl;
}
}
return 0;
}
by lgy2024 @ 2023-05-18 15:32:37
先埃筛,再判回文