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