#include <cstdio> #include <iostream> #include <string h=""> #include <cmath> using namespace std; bool isPrime(int x) { for(int i=2;i*i<=x;++i) if(x%i==0) return false; return true; } bool yes(int x) { int L=0; //几位 int tx=x; while(tx!=0) { L++; tx/=10; } int tp=x; int ss=1; for(int i=1;i<L;++i) ss*=10; for(int i=1;i<=L;++i) { int high=tp/ss; int newx=tp%ss*10+high; if(false==isPrime(newx)) return false; tp=newx; } return true; } int main() { int sum=0; for(int i=2;i<1000000;++i) if(yes(i)==true) { printf("%d\n",i); sum++; } printf("%d",sum); } </cmath></string></iostream></cstdio>