lofing @ 2024-10-11 14:29:44
在DEV上编译测试通过,为什么这里不行QAQ
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
bool array[10000001];
int esp(int b) {
memset(array,true,sizeof(array));
array[1] =array[0] = false;
int n = sqrt(b);
for(int step = 0; step <= n; step++) {
if(array[step]) {
for(int j = 2; j <= b/step; j++)
array[step * j] = false;
}
}
}
bool hw(int b) {
int temp = b,ans = 0;
while(temp != 0) {
ans=ans*10+temp%10;
temp /= 10;
}
if(ans == b)return true;
return false;
}
int main() {
int a,b;
cin>>a>>b;
esp(b);
if (a%2==0) a++;
for (int i=a; i<=b; i+=2) {
if (array[i] && hw(i))
cout<<i<<endl;
}
return 0;
}