B. Ania and Minimizing

滴答滴答---题目链接 

B. Ania and Minimizing

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples

input

Copy

5 3
51528

output

Copy

10028

input

Copy

3 2
102

output

Copy

100

input

Copy

1 1
1

output

Copy

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.

#include <iostream>
#include<stdio.h>
using namespace std;

int main()
{
    int n,m;
    string s;
    scanf("%d%d",&n,&m);
    cin>>s;
    int len=s.length();
    if(m==0)
        cout<<s;
    else if(len==1)
    {
        printf("0\n");
    }
    else
    {
        int l=0;
        int r=0;
        while(m>l)
        {
            if(l==0&&r==0)
            {
                // printf("kk\n");
                if(s[0]=='1')
                {
                    cout<<1,r++;
                }
                else
                {
                    cout<<1,r++;
                    l++;
                }
            }
            else
            {
                if(s[r]=='0')
                {
                    cout<<0,r++;
                    //printf("l =%d\n",l);
                }
                else if(s[r]!=0)
                {
                    cout<<0,r++;
                    l++;
                }
            }
            if(r==len)
                break;
        }
        // cout<<l<<" "<<r<<endl;
        if(r!=len)
        {
            for(int j=r; j<len; j++)
                cout<<s[j];
        }

    }
    cout<<endl;
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值