ytr2010 @ 2023-10-01 19:58:21
#include <bits/stdc++.h>
using namespace std;
int pri[10000000]={2,2};
int l,r;
bool isprim(int x)
{
if(pri[x]!=0) return (pri[x]==1?1:0);
if(x==2) return 1;
for(int i=2;i*i<=x;i++)
{
if(x%i==0)
{
for(int i=1;i*x<r;i++)
{
pri[i*x]=2;
}
return 0;
}
}
pri[x]=1;
return 1;
}
int huiwen(long long x){
long long sum=0,t=x;
while(t)
{
sum=sum*10+t%10;
t/=10;
}
return x==sum;
}
int main()
{
cin>>l>>r;
if(l%2==0) l++;
for(int i=l;i<=r;i+=2)
{
if(isprim(i)&&huiwen(i)) cout<<i<<endl;
}
return 0;
}
by jqQt0220 @ 2023-10-01 20:08:31
十分玄学,你把 pri[10000000]={2,2}
后面的 ={2,2}
去掉就好了
by _zhang @ 2023-10-01 20:09:24
雀食
by Infinity_Fantasy @ 2023-10-01 20:09:41
@jqQt0220 有没有可能是数组开太大了
by ZhouZheyv @ 2023-10-02 22:21:24
@AK_CCF 数组开太大不会CE,直接TLE
by Infinity_Fantasy @ 2023-10-02 22:50:36
@ZhouZheyv ?
by ZhouZheyv @ 2023-10-04 08:07:58
@AK_CCF ??