Advertisement
newb_ie

generating subsequence of string(for smaller input)

Jul 8th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1.  /*
  2.     \_\
  3.    (_**)
  4.   __) #_
  5.  ( )...() => HI
  6.  || | |I|
  7.  || | |()__/
  8.  /\(___)
  9.  */
  10. #include<bits/stdc++.h>
  11. using namespace std;
  12. using lli = int64_t;
  13. int main(){
  14.     ios::sync_with_stdio(false);
  15.     cin.tie(nullptr);
  16.     //generating subsequence of a string for smaller input
  17.     string s;
  18.     cin >> s;
  19.     int bit = (1 << (int) s.size()) - 1;
  20.     for(int i = 1; i <= bit; i++){
  21.         int x = i,y = 0;
  22.         while(x){
  23.             if(x & 1){
  24.                 cout << s[y];
  25.             }
  26.             y += 1;
  27.             x >>= 1;
  28.         }
  29.         cout << "\n";
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement