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