#include <iostream>
using namespace std;
int a[23], n, k, m;
int zs(int x){for(int i=2; i*i<=x; ++i) if(x%i==0) return 0; return 1;}
void dfs(int cs, int he, int id){
if(cs==n && zs(he)){m++; return;}
if(id>n) return;
for(int i=id; i<=n; ++i){
dfs(cs+1, he+a[i], i+1);
dfs(cs, he, i+1);
}
}
int main(){
cin>>n>>k;
for(int i=1; i<=n; ++i) cin>>a[i];
dfs(0, 0, 1);
cout<<m;
}
初次手打 dfs 有点生
求助
QwQ