/* ID:tianlin2 PROG:sprime LANG:C++ */ #include <iostream> #include <fstream> #include <cmath> using namespace std; int n; ofstream fout("sprime.out"); int isprm(int a) { if(a<2) return 0; int j=2; while(j<=sqrt((double)a)&&a%j!=0) ++j; if(j>sqrt((double)a)) return 1; return 0; } void find(int sum,int count) { if(count==n){ fout<<sum<<endl; return; } for(int i=1;i<=9;++i){ if(count>0&&(i%2==0||i==5)) continue; sum=sum*10+i; if(isprm(sum)) find(sum,count+1); sum=(sum-i)/10; } } int main() { ifstream fin("sprime.in"); fin>>n; find(0,0); fout.close(); //system("pause"); return 0; }