303717: CF718A. Efim and Strange Grade

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Efim and Strange Grade

题意翻译

zpy刚刚学了小数四舍五入进位,对于某一位上的小数,如果对其进行四舍五入进位,那么大于等于5的就向前进一位,此位及后面的所有数字都变0,小于等于4就不进位,此位及后面的所有数字都变0。 现在有一个实数,zpy有t次机会对其中某些小数进行四舍五入进位(t次不用光也没关系),他想知道,最大可以让这个数字变成多少? 比如实数为1.299996121,t=5,BSNY可以选择让第一个9就四舍五入变成1.300000000,这是最大的数了,输出的时候需要将后缀的多余0去掉,输出1.3 输入的数字可能很大,用字符串形式输入 第一行输入n, t,表示字符串的长度和t次机会 第二行输入这个实数,这个实数保证小数点后面有数字,没有前缀0和后缀0,不会出现“001.2”, “0.1200”, “.01”, “10”等等这样的数字。 输出 输出四舍五入后最大的数 注意四舍五入只针对小数部分,不针对整数 输出的时候同样也不能有前缀0和后缀0 如果最大的数变成整数了,那么不要输出小数点了,例如不能输出“1.”

题目描述

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 $ .

输入输出格式

输入格式


The first line of the input contains two integers $ n $ and $ t $ ( $ 1<=n<=200000 $ , $ 1<=t<=10^{9} $ ) — 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 $ .

输出格式


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

输入输出样例

输入样例 #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.

Input

题意翻译

zpy刚刚学了小数四舍五入进位,对于某一位上的小数,如果对其进行四舍五入进位,那么大于等于5的就向前进一位,此位及后面的所有数字都变0,小于等于4就不进位,此位及后面的所有数字都变0。 现在有一个实数,zpy有t次机会对其中某些小数进行四舍五入进位(t次不用光也没关系),他想知道,最大可以让这个数字变成多少? 比如实数为1.299996121,t=5,BSNY可以选择让第一个9就四舍五入变成1.300000000,这是最大的数了,输出的时候需要将后缀的多余0去掉,输出1.3 输入的数字可能很大,用字符串形式输入 第一行输入n, t,表示字符串的长度和t次机会 第二行输入这个实数,这个实数保证小数点后面有数字,没有前缀0和后缀0,不会出现“001.2”, “0.1200”, “.01”, “10”等等这样的数字。 输出 输出四舍五入后最大的数 注意四舍五入只针对小数部分,不针对整数 输出的时候同样也不能有前缀0和后缀0 如果最大的数变成整数了,那么不要输出小数点了,例如不能输出“1.”

加入题单

上一题 下一题 算法标签: