Ania has a large integer SS. Its decimal representation has length nn and doesn’t contain any leading zeroes. Ania is allowed to change at most kk digits of SS. She wants to do it in such a way that SS 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 nn and kk (1≤n≤2000001≤n≤200000, 0≤k≤n0≤k≤n) — the number of digits in the decimal representation of SS and the maximum allowed number of changed digits.

The second line contains the integer SS. It’s guaranteed that SS has exactly nn digits and doesn’t contain any leading zeroes.

Output

Output the minimal possible value of SS which Ania can end with. Note that the resulting integer should also have nn digits.

Sample Input

5 3
51528

3 2
102

1 1
1

Sample Output

10028

100

0

Note

A number has leading zeroes if it consists of at least two digits and its first digit is 00. For example, numbers 0000, 0006900069 and 01010101 have leading zeroes, while 00, 30003000 and 10101010 don’t have leading zeroes.

题目大意:

一个 n 位数,经过 k 次变化, 输出变化 k 次后的最小值, 且这个 n 位数没有前导 0。

解题思路:

如果是多位数使首位为1,其余位为0,如果为单位数直接为0。

代码如下:

#include <stdio.h>
#include <string.h>
char s[200002];
int main()
{int n,k,i=0,j=0;scanf("%d%d%s",&n,&k,&s);for(i=0;i<n;i++){if(j<k&&k>0){if(s[0]!='1'&&i==0){s[i]='1';j++;}else if(i!=0&&s[i]!='0'){s[i]='0';j++;}if (n==1){s[i]='0';}}else{break;}}printf("%s",s);
}

Ania and Minimizing相关推荐

  1. CodeForces Ania and Minimizing 1230B

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

  2. G - Ania and Minimizing(模拟)

    Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading ...

  3. CF专题(长安大学)

    来暂时总结下这几天的CF专题吧-后续还会更新- A - Ichihime and Triangle: Ichihime is the current priestess of the Mahjong ...

  4. tf2: Gradients do not exist for variables when minimizing the loss.

    WARNING:tensorflow:Gradients do not exist for variables when minimizing the loss. 情况一 该变量没有参与最后loss的 ...

  5. 一周一论文(翻译)——[VLDB 19] Minimizing Cost by Reducing Scaling Operators in Distributed Stream Processing

    Abstract 弹性分布式流处理系统能够动态地适应工作负载的变化.通常,这些系统通过向上或向下扩展来对输入数据的速率或资源利用水平做出反应.目标是优化系统的资源使用,从而降低其运营成本.但是,这种扩 ...

  6. Binary String Minimizing CodeForces - 1256D(贪心)

    You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). I ...

  7. Minimizing Difference CodeForces - 1244E(贪心题)

    题目 题意 官方题解: 百度翻译 思路 ac代码 题意 给出一列数,至多n个操作使其中的数+1或-1,要求得到最小的差值(最大值-最小值): You are given a sequence a1_{ ...

  8. Keras 找不到权重的梯度 WARNING:tensorflow:Gradients do not exist for variables when minimizing the loss

    问题: 在构建复数网络的时候,需要按照实部real与虚部image来分别创建计算权重: shape = (2,) + (input_dim, self.units) # dense层构建全连接矩阵 s ...

  9. 生成性对抗网络技术实现

    生成性对抗网络技术实现 Generative Adversarial Networks 以某种形式,使用深度神经网络学习从数据点到标签的映射.这种学习被称为区别性学习,因为希望能够区分猫和狗的照片.量 ...

最新文章

  1. PostgreSQL_case when
  2. java severlet教程_javaweb-severlet
  3. 论文总结:Fast and Light Bandwidth Testing for Internet Users(21‘ NSDI)
  4. mysql返回行数_如何计算MySQL查询返回的行数?
  5. mysql 查询 int类型日期转换成datetime类型
  6. 智能优化算法:海鸥优化算法-附代码
  7. 【显卡天梯图】2014年最新显卡天梯图 – 【迄今最全系列显卡】
  8. 用LeapFTP上传文件碰到的问题及解决办法
  9. 推荐5款免费网盘,空间大不限速!
  10. 日版IPhone5完美上3G
  11. 未能加载文件或程序集“XXXX”或它的某一个依赖项。试图加载格式不正确的程序。(已解决)
  12. 域名访问限制不严格漏洞 修复
  13. 51nod1423 最大二“货”
  14. 对方接住了你人的php,接住你了表情包 - 接住你了微信表情包 - 接住你了QQ表情包 - 发表情 fabiaoqing.com...
  15. requireJs笔记
  16. 厦门大学821电子电路考研参考书目
  17. 苹果市场占有率_为什么买了苹果电脑,却要安装Windows系统
  18. modbus 调试经验
  19. c语言考试的说说带图片致自己,高中生超励志的正能量短语说说带图片致自己...
  20. CHECKMARX安全漏洞检测防止XSS(Cross Site Scripting)跨站脚本攻击

热门文章

  1. 李一鹏:一份让我无法拒绝的offer | OneFlow U
  2. 360柱状全景图拼接
  3. 一个啥都不懂但还不知天高地厚的我
  4. 2023年清华大学电子与通信工程考研上岸前辈备考经验
  5. 每日一题「整数除法」
  6. Linux/Centos: 服务器TIME_WAIT和CLOSE_WAIT区别及解决方案
  7. 假如生活欺骗了你……
  8. 因式分解机(Factorization Machines,FM )
  9. 要你命三千又三千的成长之旅
  10. mendeley导入pdf后无法打开:unable to open this file解决办法