Advertisement
Josif_tepe

Untitled

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