#AT2342. B - Broken Rounding
B - Broken Rounding
当前没有测试数据。
B - Broken Rounding
Score : $200$ points
Problem Statement
Given a non-negative integer $X$, perform the following operation for $i=1,2,\dots,K$ in this order and find the resulting $X$.
- Round $X$ off to the nearest $10^i$.
- Formally, replace $X$ with $Y$ that is "the largest multiple of $10^i$ that minimizes $|Y-X|$."
- Here are some examples:
- Rounding $273$ off to the nearest $10^2$ yields $300$.
- Rounding $999$ off to the nearest $10^3$ yields $1000$.
- Rounding $100$ off to the nearest $10^{10}$ yields $0$.
- Rounding $1015$ off to the nearest $10^1$ yields $1020$.
Constraints
- $X$ and $K$ are integers.
- $0 \le X < 10^{15}$
- $1 \le K \le 15$
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
2048 2
2100
$X$ changes as $2048 \rightarrow 2050 \rightarrow 2100$ by the operations.
1 15
0
999 3
1000
314159265358979 12
314000000000000
$X$ may not fit into a $32$-bit integer type.