-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ.cpp
74 lines (72 loc) · 1.26 KB
/
J.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
using namespace std;
const int maxn = (1<<20)+5;
int dp[maxn],col[21];
void solve(int n,int ans){
if(n==0)
return;
int t = col[n];
dp[(1<<(t-1))+ans]++;
solve(n-1,ans);
solve(n-1,ans+(1<<(t-1)));
}
int read(){
int tot=0,a;
char c;
int flag= 0;
while(1){
if(scanf("%d",&a)!=EOF){
//cout<<a<<endl;
}else{
//cout<<1<<endl;
flag = 1;break;
}
scanf("%c",&c);
//cout<<c<<endl;
col[++tot] = a;
if(c=='\n'){
//cout<<2<<endl;
break;
}
}
//cout<<tot<<endl;
solve(tot,0);
if(flag)
return -1;
return 0;
}
int main(){
//freopen("in.txt","r",stdin);
int n,m;
m = 0;
double a;
scanf("%d%lf",&n,&a);
for(int i=1;i<(1<<n);i++){
dp[i] = 0;
}
while(read()!=-1){
m++;
//cout<<"hh"<<endl;
}
m++;
a = a*m;
//cout<<a<<endl;
int ans = 0;
for(int i=1;i<(1<<n);i++){
if(dp[i]>=a){
// int t = i;
// while(t){
// if(t%2==0){
// cout<<0;
// }else{
// cout<<1;
// }
// t/= 2;
// }
// cout<<endl;
ans++;
}
}
printf("%d\n",ans);
return 0;
}