Advertisement
Josif_tepe

Untitled

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