Ania has a large integer S. Its decimal representation has length n
and doesn’t contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won’t contain any leading zeroes and it’ll be minimal possible. What integer will Ania finish with?
Input
The first line contains two integers n and k(1≤n≤200000, 0≤k≤n) — the number of digits in the decimal representation of S and the maximum allowed number of changed digits.The second line contains the integer S . It’s guaranteed that S has exactly n digits and doesn’t contain any leading zeroes.Output the minimal possible value of S which Ania can end with. Note that the resulting integer should also have n digits.
Examples
Input
5 3
51528
Output
10028
Input
3 2
102
Output
100
Input
1 1
1
Output
0
输入一个整数,最多改变K个数,使最小且无前导0
第一位最小1,其他0

#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
char a[200010];
int main()
{int n,k;cin>>n>>k>>a;if(n==1){if(k==0)cout<<a;elsecout<<0;}else{if(k==0)cout<<a;else{if(a[0]!='1') k--;a[0]='1';int tip=1;while(tip<n&&k){if(a[tip]!='0'){a[tip]='0';k--;    }tip++;}cout<<a;    }   }return 0;
}

G - Ania and Minimizing(模拟)相关推荐

  1. CodeForces Ania and Minimizing 1230B

    大家觉得写还可以,可以点赞.收藏.关注一下吧! 也可以到我的个人博客参观一下,估计近几年都会一直更新!和我做个朋友吧!https://motongxue.cn 文章目录 CodeForces Ania ...

  2. Ania and Minimizing

    Ania has a large integer SS. Its decimal representation has length nn and doesn't contain any leadin ...

  3. G代码运行模拟软件-NC Viewer

    推荐个G代码运行的模拟软件,下载链接 使用方法 "文件"-"打开"导入G代码 使用空格键可以一条一条语句执行.

  4. java模拟交通信号灯_java 多线程交通信号灯模拟过程详解

    这学期我们java课程的课程设计项目----交通信号灯的线程设计 实验目的:多线程设计,同步机制 题意 设计一个交通信号灯类: 变量:位置.颜色(红.黄.绿).显示时间(秒). 方法:切换信号灯. 创 ...

  5. 自由落体java编程_java模拟自由落体运动源代码

    简单做了一个 import java.awt.borderlayout; import java.awt.button; import java.awt.color; import java.awt. ...

  6. 人脸照片自动生成游戏角色_ICCV2019论文解析

    人脸照片自动生成游戏角色_ICCV2019论文解析 Face-to-Parameter Translation for Game Character Auto-Creation 论文链接: http: ...

  7. C语言读取bmp图像并做简单显示

    C语言读取bmp图像并做简单显示) bmp文件格式 读取bmp文件信息并展示 bmp文件格式 bmp文件大体上分为四个部分: bmp文件构成 位图文件头BITMAPFILEHEADER 位图信息头BI ...

  8. 带你上手全新版本的Webpack 5

    摘要:webpack5快速入门,船新版本,建议收藏 本文分享自华为云社区<webpack5快速入门,船新版本,建议收藏>,作者:北极光之夜.. 一. 快速上手 1.1 Webpack功能: ...

  9. 2021年度训练联盟热身训练赛第二场(ICPC North Central NA Contest 2019,南阳师范学院),签到题ABCDEFGIJ

    A. Binarize It,简单枚举 链接:https://ac.nowcoder.com/acm/contest/12794/A 来源:牛客网 题目描述 Professor Boolando ca ...

最新文章

  1. PostgreSQL中的大容量空间探索时间序列数据存储
  2. 如何在JavaScript中比较数组?
  3. 关于外挂新手最常见的30个问题
  4. python并发编程之多线程理论部分
  5. 高仿精仿手机版QQ空间应用源码
  6. C++11 多线程 基础
  7. vrep中的a dubins state space
  8. 节能与新能源汽车技术路线图2.0 pdf_《节能与新能源汽车技术路线图(2.0版)》正式发布...
  9. 20分钟充满!华为P50系列或最高支持100W超级快充
  10. python练手经典100例-推荐几个适合新手练手的Python项目《python入门例子》
  11. TreeSet与TreeMap
  12. 风暴过后的小红书破圈解题,社区价值或被重估
  13. 关于pycharm中代码为灰色以及如何调整代码检查级别的问题
  14. android微信图片编辑带滤镜,微信更新了一个小功能,一些图片编辑软件可能要被打入冷宫了...
  15. 根据日期、时间和当地经纬度计算太阳天顶角和方位角的原理
  16. Java算术右移和逻辑右移
  17. 软件项目的规模、工作量和成本是如何进行估算的
  18. 如何将彩色文本打印到终端?
  19. 哈尔滨工业大学(深圳)本科毕业设计(论文)LaTeX模板:hitszthesis
  20. 了解Maxicode二维码

热门文章

  1. 支持向量机(SVM)的数学原理
  2. 川崎机器人 AS语言基础运动指令表
  3. Far planner 部署真实小车 树莓派部署lego_loam
  4. 接口与接口、接口与类之间的关系
  5. 定时计数器c语言编程,定时计数器T0作定时应用技术(一)
  6. 工具推荐|2019年UI设计师必备工具清单
  7. Java面试中的常见问题
  8. 【CSDN竞赛第5期】编程竞赛总结
  9. 家乡主题网页设计代码 旅游主题网页设计 html静态网页设计制作 dw静态网页成品模板素材网页 web前端网页设计与制作 div静态网页设计
  10. 【一致性仿真】Consensus of second-order heterogeneous multi-agent systems with and without input saturation