满江红 只做了n==4
#include<bits/stdc++.h>
using namespace std;
bool zhi(int x)
{
for(int i=2;i*i<=x;i++)
{
if(x%i==0) return 0;
}
return 1;
}
int main()
{
int n;bool k;
cin >> n;
if(n==4)
{
for(int i=1000;i<10000;i++)
{
k=0;
k=zhi(i);
if(k==1)
{
k=0;
k=zhi(i%10);
if(k==1)
{
k=0;
k=zhi(i/10%10);
if(k==1)
{
k=0;
k=zhi(i/100%10);
if(k==1)
{
k=0;
k=zhi(i/1000);
if(k==1) cout << i << endl;
}
}
}
}
}
}
return 0;
}