58分求调,一直卡,调好必关
  • 板块P1106 删数问题
  • 楼主liyuyi
  • 当前回复1
  • 已保存回复1
  • 发布时间2025/7/23 18:59
  • 上次更新2025/7/24 08:14:53
查看原帖
58分求调,一直卡,调好必关
1106187
liyuyi楼主2025/7/23 18:59
#include<bits/stdc++.h>
using namespace std;
string n;
int k,c=0,i=0,s=0;
int main()
{
	cin>>n>>k;
	while(1){
		if(n[i]>n[i+1]){
			n.erase(i,1);
			i=0;
			c++;
			if(c==k){
				break;
			}
		}
        else i++;
	}
	if(n.size()==1){
		cout<<n;
	}
	else{
		for(int i=0;i<=n.size();i++){
			if(n[i]=='0') n.erase(i,1);
		}
		cout<<n;
	}
	return 0;
} 
2025/7/23 18:59
加载中...