Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. typedef long long lint;
  4. int main()
  5. {
  6.     int n;
  7.     lint a,b;cin>>n>>a>>b;
  8.     int ar[40];
  9.     for(int x=0;x<n;x++)
  10.     cin>>ar[x];
  11.     lint ans=0;
  12.  
  13.     for(lint x=1;x<(1LL<<n);x++)
  14.     {lint sum=0;
  15.         lint ll=x;
  16.         for(int m=0;ll;ll>>=1,m++)
  17.         {
  18.             if(ll&1)
  19.             sum+=ar[m];
  20.             if(sum>b)break;
  21.         }
  22.         if(sum>=a&&sum<=b)ans++;
  23.     }
  24.     if(a<=0&&b>=0)ans++;
  25.     cout<<ans;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement