题目链接:https://www.luogu.org/problemnew/show/P1036
#include <bits/stdc++.h>
using namespace std;
int n,k,ans,sum;
int x[101];
bool judge(int x)
{
if(x<2)return false;
for(int i=2;i<=sqrt(x);i++)
{
if(x%i==0)return false;
}
return true;
}
void dfs(int step,int sum,int cnt)
{
if(step==n+1||cnt==k)
{
if(judge(sum)&&cnt==k)ans++;
return ;
}
dfs(step+1,sum+x[step],cnt+1);
dfs(step+1,sum,cnt);
return ;
}
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>x[i];
dfs(1,0,0);
cout<<ans<<endl;
return 0;
}