-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj1182.cpp
More file actions
44 lines (37 loc) · 882 Bytes
/
boj1182.cpp
File metadata and controls
44 lines (37 loc) · 882 Bytes
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
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <set>
using namespace std;
const int MAX = 10e+6;
const int INF = 0x66554433;
int arr[21];
int answer;
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main(){
Quick_IO();
int n, s;
cin>>n>>s;
for (int i = 0; i < n; ++i) cin>>arr[i];
for(int k = 0;k<n;k++) {
vector<bool> comb(n-k, true);
for(int j = 0;j<k;j++) comb.push_back(false);
do {
int tempSum = 0;
for (int i = 0; i < n; i++) {
if (comb[i])
tempSum += arr[i];
}
if (tempSum == s) answer++;
} while (prev_permutation(comb.begin(), comb.end()));
}
cout<<answer<<"\n";
return 0;
}