You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
664 B
26 lines
664 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
//共删除k个数字
|
|
int K;
|
|
//输入的字符串
|
|
string s;
|
|
|
|
int main() {
|
|
//输入
|
|
cin >> s >> k;
|
|
//共删除k个数字
|
|
while (k--) {
|
|
//找高峰期,每次都需要从头开始找
|
|
int i = 0;
|
|
for (; s[i] <= s[i + 1]; i++);
|
|
//删除函数,就是从第i个位置连续删1个。
|
|
//如果一个也没有找到,说明没有峰值出现,那么它默认会干掉最后一个~
|
|
s.erase(i, 1);
|
|
}
|
|
//处理前导零
|
|
while (s[0] == '0' && s.size() > 1) s.erase(0, 1);
|
|
//输出大吉
|
|
cout << s << endl;
|
|
return 0;
|
|
} |