42 lines
652 B
C++
42 lines
652 B
C++
#include <iostream>
|
|
#include <cmath>
|
|
using namespace std;
|
|
int shu,chang,flag=0,ans=0;
|
|
bool pan(int n){
|
|
if(n<2){
|
|
return 0;
|
|
}
|
|
if(n==2){
|
|
return 1;
|
|
}
|
|
int len=sqrt(n);
|
|
for(int i=2;i<=len;i++){
|
|
if(n%i==0){
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
void dg(int now){
|
|
if(now==chang+1){
|
|
if(pan(flag)==1){
|
|
ans++;
|
|
}
|
|
}else{
|
|
for(int i=1;i<=shu;i++){
|
|
flag*=10;
|
|
flag+=i;
|
|
dg(now+1);
|
|
flag/=10;
|
|
}
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
cin>>shu>>chang;
|
|
dg(1);
|
|
cout<<ans;
|
|
}
|