Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <set>
- #include <string>
- #include <algorithm>
- using namespace std;
- using ll = long long;
- void co(vector <int> v){
- for (auto x: v) cout<<x<<' ';
- cout<<'\n';
- }
- int main()
- {
- int n;
- cin>>n;
- int R;
- cin>>R;
- vector <int> r(n);
- for (int &x: r) cin>>x;
- int ans = 0;
- //vector <int> now;
- //vector <vector <int> > all;
- for (int mask = 0; mask < (1 << n); mask++) {
- //now.clear();
- int Ri = 0;
- for (int i = 0; i < n; ++i) {
- if (mask & (1 << i)) {
- //cout << 1;
- Ri += r[i];
- //now.push_back(r[i]);
- }
- /*else {
- //cout << 0;
- }*/
- }//cout << '\n';
- if (Ri == R) {
- ans++;
- //all.push_back(now);
- //co(now);
- //cout<<"YES"<<endl;
- }
- }
- /*
- cout<<'\n';
- co(r);
- cout<<"all\n";
- for (auto x: all) co(x);
- cout<<"ans = ";*/
- cout<<ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement