#abc099c. C - Strange Bank
C - Strange Bank
Score : points
问题描述
为限制取款的便利性,某银行规定其客户在单次操作中仅能取出以下金额之一:
-
1 日元(日本货币)
-
6 日元、6^2(=36)日元、6^3(=216)日元,...
-
9 日元、9^2(=81)日元、9^3(=729)日元,...
至少需要进行多少次操作才能精确取出总计 N 日元?
不允许将已取出的资金再次存入。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:
-
yen (the currency of Japan)
-
yen, yen, yen, ...
-
yen, yen, yen, ...
At least how many operations are required to withdraw exactly yen in total?
It is not allowed to re-deposit the money you withdrew.
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
If at least operations are required to withdraw exactly yen in total, print .
Sample Input 1
127
Sample Output 1
4
By withdrawing yen, yen, yen and yen, we can withdraw yen in four operations.
Sample Input 2
3
Sample Output 2
3
By withdrawing yen three times, we can withdraw yen in three operations.
Sample Input 3
44852
Sample Output 3
16
update @ 2024/3/10 17:19:09