A - Scary Fee Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 150150

問題文

あなたはコワスギ銀行の通帳を持っています。コワスギ銀行の預金通帳には、引き出し額に応じて手数料が変わるという怖すぎる性質があります。

コワスギ銀行の通帳からお金を引き出すには、10001\,000 円単位で引き出し額を指定したうえで、引き出し額 10001\,000 円あたり CC 円の手数料を残高から別途支払う必要があります。銀行の残高が 00 円未満になる引き出しを行うことはできません。

あなたが持っているコワスギ銀行の通帳の残高が XX 円のとき、そこから最大で何円を引き出せますか?

制約

  • 1X1071 \leq X \leq 10^7
  • 1C9991 \leq C \leq 999
  • 入力される値はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

XX CC

出力

答えを出力せよ。


入力例 1Copy

Copy
650000 8

出力例 1Copy

Copy
644000

644000644\,000 円を引き出すために必要な手数料は 644000×81000=5152644\,000 \times \displaystyle\frac{8}{1000} = 5\,152 円になるので、644000+5152650000644\,000 + 5\,152 \leq 650\,000 より、644000644\,000 円は引き出すことができます。

一方で、645000645\,000 円引き出すために必要な手数料は 645000×81000=5160645\,000 \times \displaystyle\frac{8}{1000} = 5\,160 円になるので、645000+5160>650000645\,000 + 5\,160 > 650\,000 より、645000645\,000 円は引き出すことができません。


入力例 2Copy

Copy
1003 4

出力例 2Copy

Copy
0

まったくお金が引き出せないこともありえます。


入力例 3Copy

Copy
10000000 24

出力例 3Copy

Copy
9765000

Score : 150150 points

Problem Statement

You have a bankbook from The Terrifying Bank. The deposit passbook of the bank has a terrifyingly scary property that the commission fee changes according to the withdrawal amount.

To withdraw money from the passbook, you need to specify the withdrawal amount in units of 10001\,000 yen, and pay a commission fee of CC yen per 10001\,000 yen of withdrawal amount separately from the balance. Withdrawals are not allowed if they would leave the balance below 00 yen.

When the balance of your passbook from the bank is XX yen, what is the maximum amount of money you can withdraw from it?

Constraints

  • 1X1071 \leq X \leq 10^7
  • 1C9991 \leq C \leq 999
  • All input values are integers.

Input

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

XX CC

Output

Output the answer.


Sample Input 1Copy

Copy
650000 8

Sample Output 1Copy

Copy
644000

The commission fee required to withdraw 644000644\,000 yen is 644000×81000=5152644\,000 \times \displaystyle\frac{8}{1000} = 5\,152 yen, so since 644000+5152650000644\,000 + 5\,152 \leq 650\,000, you can withdraw 644000644\,000 yen.

On the other hand, the commission fee required to withdraw 645000645\,000 yen is 645000×81000=5160645\,000 \times \displaystyle\frac{8}{1000} = 5\,160 yen, so since 645000+5160>650000645\,000 + 5\,160 > 650\,000, you cannot withdraw 645000645\,000 yen.


Sample Input 2Copy

Copy
1003 4

Sample Output 2Copy

Copy
0

It is possible that no money can be withdrawn at all.


Sample Input 3Copy

Copy
10000000 24

Sample Output 3Copy

Copy
9765000


2025-09-21 (Sun)
18:13:10 +09:00