IKOvillage @ 2024-08-30 23:12:49
#include<bits/stdc++.h>
using namespace std;
long long a,b,g,n,h;
bool check(int x)
{
if(x <= 2) return false;
if(x%2==0) return false;
if((x!=11)&&(x%11==0)) return false;
for(int i = 2; i <= sqrt(x); i++)
if(x % i == 0) return false;
return true;
}
bool hws(int num) {
int temp=num,ans=0;
while (temp!=0) {
ans=ans*10+temp%10;
temp/=10;
}
if (ans==num)
return true;
else
return false;
}
int main(){
cin>>a>>b;
if(a%2==0)a++;
for(int i=a;i<=b;i+=2)
{
if(i>=9989900) break;
if(check(i)&& hws(i)) cout<<i<<endl;
}
return 0;
}
求调
by liruizhou_lihui @ 2024-08-30 23:18:18
if(check(i)&& hws(i))中的&&会短路运算,把两个颠倒AC因为hws复杂度低