Advertisement
Nusrat_Ullah

K subset

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