https://www.luogu.com.cn/problem/P1036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PII;
typedef vector<long long> VI;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define pb(i) push_back(i)
#define int long long
#define INF 0x3f3f3f3f
#define oz 998244353
#define endl '\n'
#define N 200010
const int mod = 1e9 + 7;
int p[N], si[N];
int find(int x) {
if (x != p[x]) p[x] = find(p[x]);
return p[x];
}
//size[find(b)] += size[find(a)];
//p[find(a)] = find(b);
int n, k, res = 0;
VI a(25);
int prime(int x) {
if (x < 4)return 1;
for (int i = 2; i <= x / i; i++) {
if (x % i == 0)return 0;
}
return 1;
}
int st[25]; // 0未考虑 1选 2不选
void dfs(int x, int y) {
if (y > k) {
int sum = 0;
rep(i, 1, n) {
if (st[i] == 1)sum += a[i];
}
res += prime(sum);
return ;
}
if (x > n)return;
st[x] = 1;
dfs(x + 1, y + 1);
st[x] = 0;
st[x] = 2;
dfs(x + 1, y);
st[x] = 0;
}
void solve() {
cin >> n >> k;
rep(i, 1, n)cin >> a[i];
dfs(1, 1);
cout << res << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int T = 1;
// cin >> T;
while (T --)
solve();
return 0;
}