CF121B.Lucky Transformation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya has a number consisting of nn digits without leading zeroes. He represented it as an array of digits without leading zeroes. Let's call it dd . The numeration starts with 11 , starting from the most significant digit. Petya wants to perform the following operation kk times: find the minimum xx (1<=x<n) such that dx=4d_{x}=4 and dx+1=7d_{x+1}=7 , if xx is odd, then to assign dx=dx+1=4d_{x}=d_{x+1}=4 , otherwise to assign dx=dx+1=7d_{x}=d_{x+1}=7 . Note that if no xx was found, then the operation counts as completed and the array doesn't change at all.

You are given the initial number as an array of digits and the number kk . Help Petya find the result of completing kk operations.

输入格式

The first line contains two integers nn and kk (1<=n<=105,0<=k<=109)(1<=n<=10^{5},0<=k<=10^{9}) — the number of digits in the number and the number of completed operations. The second line contains nn digits without spaces representing the array of digits dd , starting with d1d_{1} . It is guaranteed that the first digit of the number does not equal zero.

输出格式

In the single line print the result without spaces — the number after the kk operations are fulfilled.

输入输出样例

  • 输入#1

    7 4
    4727447
    

    输出#1

    4427477
    
  • 输入#2

    4 2
    4478
    

    输出#2

    4478
    

说明/提示

In the first sample the number changes in the following sequence: 472744744274474427477442744744274774727447→4427447→4427477→4427447→4427477 .

In the second sample: 4478477844784478→4778→4478 .

首页