No.2681 Currency Exchange at the Game Center
Problem Statement
You hold $Y$ Japanese yen in such a way that the number of pieces of currency you hold is minimized.
To play at a game center, you want at least $C$ 100-yen coins.
So you have decided to make exchanges by using a change machine one or more times.
When you insert one piece of currency worth 500 yen or more (say, worth $X$ yen) into this machine, you can receive any combination of currency totaling $X$ yen that is made up of 100-yen coins and 500-yen coins.
Example: Insert a 5000-yen bill. Receive 25 100-yen coins and 5 500-yen coins.
First, determine whether it is possible to obtain $C$ or more 100-yen coins, and if it is not possible, print can't exchange.
Otherwise, determine whether you need to use the change machine one or more times, and if you do not need to, print no exchange.
Otherwise, print the minimum possible number of 100-yen coins you hold after making exchanges so that the condition is satisfied.
The available types of currency are 1 yen, 5 yen, 10 yen, 50 yen, 100 yen, 500 yen, 1000 yen, 2000 yen, 5000 yen, and 10000 yen.
Input
$C\ Y$
- All inputs are integers
- $0 \le C \le 10^7$
- $0 \le Y \le 10^9$
Output
Print a newline at the end.
Sample
Sample 1
Input
1 1234
Output
no exchange
Sample 2
Input
5 500
Output
5
Sample 3
Input
1 99
Output
can't exchange
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
SPD_9X2
だれ
kyawa