Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 点
問題文
あなたはコワスギ銀行の通帳を持っています。コワスギ銀行の預金通帳には、引き出し額に応じて手数料が変わるという怖すぎる性質があります。
コワスギ銀行の通帳からお金を引き出すには、 円単位で引き出し額を指定したうえで、引き出し額 円あたり 円の手数料を残高から別途支払う必要があります。銀行の残高が 円未満になる引き出しを行うことはできません。
あなたが持っているコワスギ銀行の通帳の残高が 円のとき、そこから最大で何円を引き出せますか?
制約
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
答えを出力せよ。
入力例 1Copy
650000 8
出力例 1Copy
644000
円を引き出すために必要な手数料は 円になるので、 より、 円は引き出すことができます。
一方で、 円引き出すために必要な手数料は 円になるので、 より、 円は引き出すことができません。
入力例 2Copy
1003 4
出力例 2Copy
0
まったくお金が引き出せないこともありえます。
入力例 3Copy
10000000 24
出力例 3Copy
9765000
Score : 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 yen, and pay a commission fee of yen per yen of withdrawal amount separately from the balance. Withdrawals are not allowed if they would leave the balance below yen.
When the balance of your passbook from the bank is yen, what is the maximum amount of money you can withdraw from it?
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output the answer.
Sample Input 1Copy
650000 8
Sample Output 1Copy
644000
The commission fee required to withdraw yen is yen, so since , you can withdraw yen.
On the other hand, the commission fee required to withdraw yen is yen, so since , you cannot withdraw yen.
Sample Input 2Copy
1003 4
Sample Output 2Copy
0
It is possible that no money can be withdrawn at all.
Sample Input 3Copy
10000000 24
Sample Output 3Copy
9765000