俺尽量缩短了运算
但是最后一个点还是打出了1.13s
求助捏
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,l,r,n;
char m[9];
bool c;
cin>>a>>b;
for(int i=a;i<=b;++i)
{
c=1;
l=0;
r=0;
n=i;
while(n!=0)
{
m[l]=n%10+'0';
n/=10;
l++;
}
l--;
n=i;
a=1;
if(l==1)
{
cout<<n<<endl;
continue;
}
while(l>r&&a!=0)
{
if(m[l]!=m[r])
{
a=0;
break;
}
l--;
r++;
}
if(a!=0)
{
for(int j=2;j<=sqrt(n);++j)
{
if(n%j==0)
{
a=0;
break;
}
}
if(a==1)
cout<<n<<endl;
}
}
return 0;
}