marmotgreatagain @ 2024-08-22 10:43:16
#include<iostream>
#define maxsize 100
using namespace std;
int zhishu(int n)
{
int tag=1;
if(n==1)
{
return 0;
}
if(n==2)
{
return 2;
}
for(int i=2;i<n;i++)
{
if(n%i==0)
{
tag=0;
break;
}
}
if(tag==1) return n;
else return tag;
}
int huiwen(int n)
{
int i=n;
int m=0;
while(i>0)
{
m=m*10+i%10;
i/=10;
}
if(m==n)
{
return n;
}
else
{
return 0;
}
}
int main()
{
int a,b;
int arr[maxsize];
cin>>a>>b;
for(int i=a;i<=b;i++)
{
if(huiwen(i))
{
if(zhishu(i))
{
cout<<i<<endl;
}
}
}
return 0;
}
by _joker_r @ 2024-08-22 10:47:43
@marmotgreatagain https://www.luogu.com.cn/article/eksn23nt
by dongzirui0817 @ 2024-08-22 10:49:31
@marmotgreatagain 搜质数时,只要搜到 for(int i=2;i<n;i++)
改为
for(int i=2;i*i<=n;i++)