Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- string s;
- cin >> s;
- int k;
- cin >> k;
- string result = "";
- int n = s.size();
- for(int bitmask = 0; bitmask < (1 << n); bitmask++) {
- string tmp = "";
- for(int i = 0; i < n; i++) {
- if(bitmask & (1 << i)) {
- tmp += s[i];
- }
- }
- if(tmp.size() == n - k)
- result = max(result, tmp);
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement