Dawn_Zhang @ 2024-08-25 10:54:36
#include<bits/stdc++.h>
using namespace std;
int cnt;
bool a[100000001]={1,1};
int n,m;
int b[100000001];
int fun(int ans){
int t=ans,sum=0;
while(t!=0){
sum=sum*10+t%10;
t/=10;
}
if(sum==ans)return 0;
else return 1;
}
void oula(){
for(int i=2;i<=m;i++){
if(a[i]==0)b[++cnt]=i;
for(int j=1;j<=cnt;j++){
if(i*b[j]>m)break;
a[i*b[j]]=1;
if(i%b[j]==0)break;
}
}
}
int main(){
cin>>n>>m;
oula();
if(n%2==0)n++;
for(int i=n;i<=m;i+=2){
if(fun(i)==0&&a[i]==0)cout<<i<<endl;
}
return 0;
}
by hhztl @ 2024-08-25 10:55:49
@Dawn_Zhang 数组定太大了
by lcx_13456 @ 2024-08-25 10:57:00
int类型的数组全局范围内最多开到10^7
by Dawn_Zhang @ 2024-08-25 10:57:05
@hhztl 大佬那10的7次方可以吗
by hhztl @ 2024-08-25 10:58:36
@Dawn_Zhang
by hhztl @ 2024-08-25 10:59:17
@Dawn_Zhang 所以你看一眼提示
by Dawn_Zhang @ 2024-08-25 11:47:14
@hhztl 感谢大佬