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