Guest User

Untitled

a guest
Nov 13th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5. string s;
  6. cin>>s;
  7. long n=(1<<s.size())-1; // 1000000-1
  8. // long n=0;
  9. // for(int i=0;i<s.size();i++){
  10. // n+=(1<<i); // 111111
  11. // }
  12. set<string> ans;
  13. for(long i=1;i<=n;i++){
  14. // long num=i;
  15. string temp;
  16.  
  17. for(int j=0;j<s.size();j++){
  18. if((i & (1<<j))!=0){ //check jth bit
  19. temp.push_back(s[j]);
  20. }
  21. }
  22.  
  23. // int count=0;
  24. // while(num>0){
  25. // if(num&1){
  26. // temp.push_back(s[count]);
  27. // }
  28. // num=num>>1;
  29. // count++;
  30. // }
  31.  
  32. ans.insert(temp);
  33. }
  34. for(auto i: ans){
  35. cout<<i<<endl;
  36. }
  37. cout<<ans.size()<<endl;
  38. return 0;
  39. }
Add Comment
Please, Sign In to add comment