CF718A.Efim and Strange Grade

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade at any place after the decimal point (also, he can ask to round to the nearest integer).

There are t seconds left till the end of the break, so Efim has to act fast. Help him find what is the maximum grade he can get in no more than t seconds. Note, that he can choose to not use all t seconds. Moreover, he can even choose to not round the grade at all.

In this problem, classic rounding rules are used: while rounding number to the n-th digit one has to take a look at the digit n + 1. If it is less than 5 than the n-th digit remain unchanged while all subsequent digits are replaced with 0. Otherwise, if the n + 1 digit is greater or equal to 5, the digit at the position n is increased by 1 (this might also change some other digits, if this one was equal to 9) and all subsequent digits are replaced with 0. At the end, all trailing zeroes are thrown away.

For example, if the number 1.14 is rounded to the first decimal place, the result is 1.1, while if we round 1.5 to the nearest integer, the result is 2. Rounding number 1.299996121 in the fifth decimal place will result in number 1.3.

埃菲姆刚刚收到了他上次测验的成绩。他在一所特殊学校学习,因此他的成绩可以是任意正的小数。起初他很失望,因为他原本期望得到一个更令人愉快的结果。接着,他制定了一个巧妙的计划:每一秒,他都可以请老师将成绩在小数点后的任意一位上进行四舍五入(也可以请求四舍五入到最接近的整数)。

距离课间休息结束还剩 tt 秒,因此埃菲姆必须迅速行动。请帮助他找出:在最多 tt 秒内,他所能获得的最高成绩是多少?注意,他可以选择不使用全部 tt 秒;甚至可以选择完全不进行任何四舍五入。

本题采用标准四舍五入规则:当将一个数四舍五入到第 nn 位小数时,需查看第 n+1n+1 位数字。若该数字小于 5,则第 nn 位数字保持不变,其后所有数字均变为 0;否则(即第 n+1n+1 位数字大于或等于 5),第 nn 位数字加 1(若该位原为 9,则可能引发更高位的进位),其后所有数字均变为 0。最后,去掉末尾所有零。

例如,将数字 1.141.14 四舍五入到第一位小数,结果为 1.11.1;而将 1.51.5 四舍五入到最接近的整数,结果为 22;将数字 1.2999961211.299996121 四舍五入到第五位小数,结果为 1.31.3。

输入格式

The first line of the input contains two integers n and t (1 ≤ n ≤ 200 000, 1 ≤ t ≤ 109) — the length of Efim's grade and the number of seconds till the end of the break respectively.

The second line contains the grade itself. It's guaranteed that the grade is a positive number, containing at least one digit after the decimal points, and it's representation doesn't finish with 0.

输入的第一行包含两个整数 nn 和 tt(1 ≤ n ≤ 200 0001 ≤ n ≤ 200\,000,1 ≤ t ≤ 1091 ≤ t ≤ 10^9),分别表示 Efim 成绩的长度以及距离课间结束的秒数。

第二行包含成绩本身。保证该成绩是一个正数,其小数点后至少有一位数字,且其表示形式不以 0 结尾。

输出格式

Print the maximum grade that Efim can get in t seconds. Do not print trailing zeroes.

输出 Efim 在 tt 秒内所能获得的最高成绩。不要输出末尾的零。

输入输出样例

  • 输入#1

    6 1
    10.245

    输出#1

    10.25
  • 输入#2

    6 2
    10.245

    输出#2

    10.3
  • 输入#3

    3 100
    9.2

    输出#3

    9.2

说明/提示

In the first two samples Efim initially has grade 10.245.

During the first second Efim can obtain grade 10.25, and then 10.3 during the next second. Note, that the answer 10.30 will be considered incorrect.

In the third sample the optimal strategy is to not perform any rounding at all.

在前两个样例中,Efim 的初始成绩为 10.24510.245。

在第一秒内,Efim 可以将成绩四舍五入为 10.2510.25,然后在下一秒内进一步四舍五入为 10.310.3。注意,答案 10.3010.30 将被视为错误。

在第三个样例中,最优策略是完全不进行任何四舍五入。

输入解题思路,AI测评打分。不知道怎么写?

首页