AtCoder Beginner Contest 208
翻译中…
Problem Statement
翻译中…
The coins used in the Kingdom of Takahashi are $1!$-yen coins, $2!$-yen coins, $\dots$, and $10!$-yen coins. Here, $N! = 1 \times 2 \times \dots \times N$.
翻译中…
Takahashi has $100$ of every kind of coin, and he is going to buy a product worth $P$ 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
翻译中…
$1 \leq P \leq 10^7$$P$is an integer.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
P
翻译中…
Output
翻译中…
Print the minimum number of coins needed.
翻译中…
样例
Input #1
9
Output #1
3
By giving one $(1! =) 1$-yen coin, one $(2! =) 2$-yen coin, and one $(3! =) 6$-yen coin, we can make the exact payment for the product worth $9$ yen. There is no way to pay this amount using fewer coins.
Input #2
119
Output #2
10
We should use one $1!$-yen coin, two $2!$-yen coins, three $3!$-yen coins, and four $4!$-yen coins.
Input #3
10000000
Output #3
24
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。