Advertisement
amstan

Iterative Subset Generation

Aug 21st, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. //Iterative Subset Generation
  2. #include <bits/stdc++.h>
  3. #include <ext/pb_ds/assoc_container.hpp>
  4.  
  5. using namespace __gnu_pbds;
  6. using namespace std;
  7. typedef long long ll;
  8.  
  9. #define mem(dp,a)           memset(dp,a,sizeof dp)
  10. #define rep(i,a,b)          for(ll i=a;i<b;i++)
  11. #define pb(x)               push_back(x)
  12. #define mp(x,y)             make_pair(x,y)
  13. #define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
  14. #define F                   first
  15. #define S                   second
  16. #define all(v)              (v).begin(),(v).end()
  17. #define pi                  3.14159265359
  18. ll INF=1e18+10;
  19. ll MOD=1000000007;
  20.  
  21. const int N=10;int n;
  22. int a[N];
  23.  
  24. int main()
  25. {
  26.     cin>>n;
  27.     rep(i,0,n)cin>>a[i];
  28.     rep(i,0,(1<<n))
  29.     {
  30.         rep(j,0,n)
  31.         if(i&(1<<j))
  32.             cout<<a[j]<<" ";
  33.         cout<<endl;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement