#P7258. [COCI 2009/2010 #3] SLATKISI

[COCI 2009/2010 #3] SLATKISI

Description

He cannot always pay the exact amount, so the shop owner made an agreement with him.

He tells the shop owner the smallest banknote he has, and the shop owner rounds the price to the closest number that he can pay.

For example, if Mirko’s smallest banknote is 100100 dollars and he wants to buy 150150 dollars of candy, the shop owner rounds the price to 200200 dollars. If he wants to buy 149149 dollars of candy, the shop owner rounds the price to 100100 dollars.

Recently, Mirko suspects that the shop owner wants to cheat him. Please determine whether the shop owner has cheated him.

Mirko’s mom only gives him banknotes of 1,10,100,103,104,105,,1091, 10, 100, 10^3, 10^4, 10^5, \cdots, 10^9 dollars, and he has infinitely many of these banknotes.

Input Format

The first line contains two integers, c,kc, k, representing the price of the candy Mirko wants to buy and the number of zeros on Mirko’s smallest banknote. Here, “number of zeros” means the exponent tt in 10t10^t.

Output Format

The first line contains one integer: cc rounded to the closest amount that Mirko can pay.

184 1

180
123450995 1

123451000
182 2

200

Hint

Constraints

For 100%100\% of the testdata, 1c1091 \le c \le 10^9, 0k90 \le k \le 9.

Notes

Translated from COCI 2009-2010 #3 T2 SLATKISI. Full score is 50 points, 5 points per test, with 10 tests in total.

Translated by ChatGPT 5