zyx20090708 @ 2023-08-03 15:43:32
#include<bits/stdc++.h>
using namespace std;
bool v[100000001];
void get_prime(int n){
memset(v,true,sizeof(v));
v[1] = false;
int b = sqrt(n);
for(int i=2;i<=b;i++){
if(v[i]){
for(int j=2;j<=n/i;j++) v[i*j] = false;
}
}
}
bool is_huiwen(int m){
int t=m,ans = 0;
while(t!=0){
ans +=t%10;
ans*=10;
t/=10;
}
return m*10 == ans;
}
int main(){
int a,b;
cin>>a>>b;
if(a>=100000000)a=9999999;
get_prime(b);
if(a>b) return 0;
if(a%2==0) a++;
for(int j=a;j<=b;j+=2){
if(v[j]&&is_huiwen(j)) cout<<j<<endl;
}
return 0;
}
by problemThief @ 2023-08-03 17:14:02
@zyx20090708
get_prime改一下
void get_prime(int n){
memset(v,true,sizeof(v));
v[1] = false;
int b = sqrt(n);
for(int i=2;i<=b;i += 2){
if(v[i]){
for(int j=2;j<=n/i;j += 2) v[i*j] = false;
}
}
}
by problemThief @ 2023-08-03 17:15:12
@zyx20090708 并且回文数都是11的倍数,你可以再写个判断...
by zyx20090708 @ 2023-08-04 10:20:52
@Rain_sun 好的,谢谢你
by Yun_Mengxi @ 2023-08-08 16:30:59
qp