#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int t[11],a,b;
bool isprime(int x) {
for(int i=2; i*i<=x; i++) {
if(x%i==0)
return false;
}
return true;
}
int wei(int x) {
int t=0;
while(x) {
x/=10;
t++;
}
return t;
}
void huiwen(int x,int h) {
int k=0;
if(h%2!=0) {
if(x>h/2) {
for(int i=0; i<h; i++) {
k=k+(t[i]*pow(10,h-i-1));
}
if(isprime(k)&&k>=a&&k<=b)
printf("%d\n",k);
return;
}
for(int i=0; i<=9; i++) {
t[x]=i;
t[h-x-1]=i;
if(t[0]!=0)
huiwen(x+1,h);
}
}
}
int main() {
scanf("%d%d",&a,&b);
if(a<=5&&b>=5)
printf("5\n");
if(a<=7&&b>=7)
printf("7\n");
if(a<=11&&b>=11)
printf("11\n");
for(int i=3; i<=wei(b); i++) {
huiwen(0,i);
}
return 0;
}
上面这段代码提交上去可以AC,但用codeblocks17.12编译后无法得到正确答案,用dev-c++5.11(我自己手动安装了GCC8.1.0)却可以,我感到很奇怪,是不是代码里有什么未定义行为?