A9131 | The Great Julya Calendar
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows:
"May the Great Beaver bless you! May your chacres open and may your third eye never turn blind from beholding the Truth! Take the magic number, subtract a digit from it (the digit must occur in the number) and get a new magic number. Repeat this operation until a magic number equals zero. The Earth will stand on Three Beavers for the time, equal to the number of subtractions you perform!"
Distinct subtraction sequences can obviously get you different number of operations. But the Smart Beaver is ready to face the worst and is asking you to count the minimum number of operations he needs to reduce the magic number to zero.
The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows:
"May the Great Beaver bless you! May your chacres open and may your third eye never turn blind from beholding the Truth! Take the magic number, subtract a digit from it (the digit must occur in the number) and get a new magic number. Repeat this operation until a magic number equals zero. The Earth will stand on Three Beavers for the time, equal to the number of subtractions you perform!"
Distinct subtraction sequences can obviously get you different number of operations. But the Smart Beaver is ready to face the worst and is asking you to count the minimum number of operations he needs to reduce the magic number to zero.
输入格式
The single line contains the magic integer $n$ , $0<=n$ .
- to get 20 points, you need to solve the problem with constraints: $n<=10^{6}$ (subproblem C1);
- to get 40 points, you need to solve the problem with constraints: $n<=10^{12}$ (subproblems C1+C2);
- to get 100 points, you need to solve the problem with constraints: $n<=10^{18}$ (subproblems C1+C2+C3).
- to get 20 points, you need to solve the problem with constraints: $n<=10^{6}$ (subproblem C1);
- to get 40 points, you need to solve the problem with constraints: $n<=10^{12}$ (subproblems C1+C2);
- to get 100 points, you need to solve the problem with constraints: $n<=10^{18}$ (subproblems C1+C2+C3).
输出格式
Print a single integer — the minimum number of subtractions that turns the magic number to a zero.
输入输出样例
输入 #1
24
输出 #1
5
In the first test sample the minimum number of operations can be reached by the following sequence of subtractions:
$24→20→18→10→9→0$
$24→20→18→10→9→0$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted