atcoder#ABC273B. [ABC273B] Broken Rounding

[ABC273B] Broken Rounding

Score : 200200 points

Problem Statement

Given a non-negative integer XX, perform the following operation for i=1,2,,Ki=1,2,\dots,K in this order and find the resulting XX.

  • Round XX off to the nearest 10i10^i.- Formally, replace XX with YY that is "the largest multiple of 10i10^i that minimizes YX|Y-X|."
    • Here are some examples:- Rounding 273273 off to the nearest 10210^2 yields 300300.
    • Rounding 999999 off to the nearest 10310^3 yields 10001000.
    • Rounding 100100 off to the nearest 101010^{10} yields 00.
    • Rounding 10151015 off to the nearest 10110^1 yields 10201020.
  • Formally, replace XX with YY that is "the largest multiple of 10i10^i that minimizes YX|Y-X|."
  • Here are some examples:
  • Rounding 273273 off to the nearest 10210^2 yields 300300.
  • Rounding 999999 off to the nearest 10310^3 yields 10001000.
  • Rounding 100100 off to the nearest 101010^{10} yields 00.
  • Rounding 10151015 off to the nearest 10110^1 yields 10201020.

Constraints

  • XX and KK are integers.
  • 0X<10150 \le X < 10^{15}
  • 1K151 \le K \le 15

Input

The input is given from Standard Input in the following format:

XX KK

Output

Print the answer as an integer.

2048 2
2100

XX changes as 2048205021002048 \rightarrow 2050 \rightarrow 2100 by the operations.

1 15
0
999 3
1000
314159265358979 12
314000000000000

XX may not fit into a 3232-bit integer type.