#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath>
using namespace std;
int main() { int ncase; char s[110], ans[110]; int m, len, sign, max, num; scanf("%d", &ncase); while(ncase--) { num = sign = 0; scanf("%s%d", s, &m); len = strlen(s); for(int i = 0; i < len - m; ++i) //找m次最大值 { max = -1; for(int j = sign; j <= m + i; ++j) //j的范围不能错~保证位数 { if(max < s[j] - ‘0‘) { max = s[j] - ‘0‘; sign = j; } } ans[num++] = s[sign++]; } for(int i = 0; i < len - m; ++i) cout<<ans[i] - ‘0‘; cout<<endl; } return 0; }
时间: 2024-11-10 02:21:27