Advertisement
Josif_tepe

Untitled

Mar 30th, 2022
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     string s;
  9.     cin >> s;
  10.     int k;
  11.     cin >> k;
  12.     string result = "";
  13.     int n = s.size();
  14.     for(int bitmask = 0; bitmask < (1 << n); bitmask++) {
  15.         string tmp = "";
  16.         for(int i = 0; i < n; i++) {
  17.             if(bitmask & (1 << i)) {
  18.                 tmp += s[i];
  19.             }
  20.         }
  21.         if(tmp.size() == n - k)
  22.             result = max(result, tmp);
  23.     }
  24.     cout << result << endl;
  25.  
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement