A. Efim and Strange Grade
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Input

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.

Output

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

Examples
input
6 1
10.245
output
10.25
input
6 2
10.245
output
10.3
input
3 100
9.2
output
9.2
Note

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.


简述题意:

他每秒可以选择是四舍五入某一位或者重新取 比如10.245 两秒-》第一秒10.25-》第二秒四舍五入10.3
n是字符串长度 t是秒
#include <stdio.h>
const int Maxn = ;
char s[Maxn];
int main() {
int n , t , i , flag = ;
scanf("%d%d",&n,&t);
scanf("%s",s+);
for(i=; i<=n; ++i) {
if(s[i] == '.') flag = ;
if(flag && s[i] >= '') {
break;
}
}
while(s[i]>='' && t--) {
if(s[i-] == '.') {
i-=;
while(s[i] == '') {
s[i] = '';
--i;
}
if(i == ) putchar('');
else ++s[i];
for(int i=; s[i] != '.'; ++i) printf("%c",s[i]);
return ;
}
else ++s[--i];
}
s[++i] = '\0';
printf("%s",s+);
}

//没交不知道A没A

//睡觉 论忘记报名的悲伤

codeforces div.1 A的更多相关文章

  1. Codeforces div.2 B. The Child and Set

    题目例如以下: B. The Child and Set time limit per test 1 second memory limit per test 256 megabytes input ...

  2. codeforces泛做..

    前面说点什么.. 为了完成日常积累,傻逼呵呵的我决定来一发codeforces 挑水题 泛做.. 嗯对,就是泛做.. 主要就是把codeforces Div.1的ABCD都尝试一下吧0.0.. 挖坑0 ...

  3. [CF787D]遗产(Legacy)-线段树-优化Dijkstra(内含数据生成器)

    Problem 遗产 题目大意 给出一个带权有向图,有三种操作: 1.u->v添加一条权值为w的边 2.区间[l,r]->v添加权值为w的边 3.v->区间[l,r]添加权值为w的边 ...

  4. Congratulations, FYMS-OIers!

    Fuzhou Yan'an Middle School Online Judge 又一次上线啦! 真的是一波三折,主要功劳必须得属于精通网页编排.ubuntu 下如何使用 rm -rf 语句但是又能够 ...

  5. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  6. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  7. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  8. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  9. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

随机推荐

  1. HTML5-Geolocation&地图.html

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...

  2. winform Config文件操作

    using System;using System.Collections.Generic;using System.Text;using System.Xml;using System.Config ...

  3. 【Qt】Qt国际化(系统文本-QMessageBox按钮、QLineEdit右键菜单等)【转】

    简介 使用Qt的时候,经常会遇到英文问题,例如:QMessageBox中的按钮.QLineEdit.QSpinBox.QScrollBar中的右键菜单等.通常情况下,我们软件都不会是纯英文的,那么如何 ...

  4. ios 控件

    反序列化 JSONModel 上拉刷新 下拉加载更多 MJRefresh AFNetworking 2.5 Asynchronous image downloader with cache - SDW ...

  5. SQL允许远程访问

    1.打开sqlserver对象资源管理器 右键 方面 常规 服务器配置 RemoteAccessEnabled true RemoteDacEnabled  true 2.打开SQL SERVER管理 ...

  6. Ubuntu 12.04 修改默认启动为字符界面

    sudo vim /etc/default/grub 修改GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" 为:GRUB_CMDLINE_LINU ...

  7. Maven入门指南⑤:使用Nexus搭建Maven私服

    1 . 私服简介 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件.有了私服之后,当 Maven 需要下载构件时,直接请求私服,私服上存在则下载到本地仓库:否则,私服请求外部 ...

  8. [JAVA][RCP]Clean project之后报错:java.lang.RuntimeException: No application id has been found.

    Clean了一下Project,然后就报了如下错误 !ENTRY com.release.nattable.well_analysis 2 0 2015-11-20 17:04:44.609 !MES ...

  9. Python中的除法

    在C/C++语言对于整形数执行除法会进行地板除(舍去小数部分).例如 int a=15/10; a的结果为1. 同样的在Java中也是如此,所以两个int型的数据相除需要返回一个浮点型数据的时候就需要 ...

  10. plateform_driver_register和plateform_device_register区别

    设备与驱动的两种绑定方式:在设备注册时进行绑定及在驱动注册时进行绑定. 以一个USB设备为例,有两种情形: (1)先插上USB设备并挂到总线中,然后在安装USB驱动程序过程中从总线上遍历各个设备,看驱 ...