根据我所学知识最快了,还是44分
#include<iostream>
#include<math.h>
using namespace std;
int nb(unsigned long long a)
{
if(a<2)
{
return 0;
}
else
{
{
for(int cs=2;cs<=sqrt(a);cs++)
{
if(a%cs==0)
{
return 0;
}
}
return 1;
}
}
}
int main()
{
unsigned long long s,n=0,m,x,i,s1=12,s2=100,a,xl;
cin>>i>>m;
for(i=i-1;i<=m;i++)
{
//筛除特殊偶数位11
if(i==11)
{
cout<<11<<endl;
s1=10;
}
//筛除偶数位
if(s1<=i&&i<s2)
{
i=s2;
s1*=100;
s2*=100;
continue;
}
if(i>=10)
{
//筛除个位
if(i%10==2||i%10==4||i%10==5||i%10==6||i%10==8||i%10==0)
continue;
//筛除首位
xl=0;
a=i;
while(a>100)
{
a=a/10;
xl++;
}
if(a/10==2||a/10==4||a/10==5||a/10==6||a/10==8||a/10==0)
{
i=i+10*pow(10,xl);
continue;
}
}
//判断回文数
s=i;
while(s!=0)
{
x=x*10+s%10;
s=s/10;
}
//判断质数
nb(i);
//输出i
if (nb(i)==1&&x==i)
cout<<i<<endl;
n=0;
x=0;
}
}