Advertisement
Nusrat_Ullah

K

Jul 5th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int g,h,t,re,s;
  6.     scanf("%d",&t);
  7.     int wq[t+3]={0};
  8.     for(g=0;g<t;g++)scanf("%d",&wq[g]);
  9.     for(g=re=0;g<(1<<t);g++){
  10.         for(h=s=0;h<t;h++)
  11.             if(g&(1<<h))s|=wq[h];
  12.         re+=s;
  13.     }
  14.     printf("%d\n",re);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement