100 atcoder#ABC208B. [ABC208B] Factorial Yen Coin
[ABC208B] Factorial Yen Coin
Score : points
Problem Statement
The coins used in the Kingdom of Takahashi are -yen coins, -yen coins, , and -yen coins. Here, .
Takahashi has of every kind of coin, and he is going to buy a product worth yen by giving the exact amount without receiving change.
We can prove that there is always such a way to make payment.
At least how many coins does he need to use in his payment?
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of coins needed.
9
3
By giving one -yen coin, one -yen coin, and one -yen coin, we can make the exact payment for the product worth yen. There is no way to pay this amount using fewer coins.
119
10
We should use one -yen coin, two -yen coins, three -yen coins, and four -yen coins.
10000000
24