Advertisement
Josif_tepe

Untitled

Jun 12th, 2022
772
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. string s;
  6. int k;
  7. cin>>s>>k;
  8. int l=s.size()-k;
  9. int x=s.size();
  10. string ans="";
  11. for(int i=0;i<(1<<x);i++)
  12. {
  13. string temp="";
  14. for(int bit=0;bit<x;bit++)
  15. {
  16. if(i & (1<<bit))
  17. {
  18. temp+=s[bit];
  19. }
  20. }
  21. //cout<<temp;
  22. if(temp.size()==l)
  23. {
  24. ans=max(ans,temp);
  25. }
  26. //cout<<endl;
  27. }
  28. cout<<ans;
  29. return 0;
  30. }
  31.  
Advertisement
RAW Paste Data Copied
Advertisement