CF331C2.The Great Julya Calendar
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
又一场末日浩劫即将来临!这次的罪魁祸首是朱利亚部落的日历。
该部落的海狸精通数学。聪明的海狸——一位考古学家——获得了一块神圣的石板,上面刻有一个“魔法整数”。石板上用古海狸语写就的铭文翻译如下:
“愿伟大的海狸赐福于你!愿你的查克雷斯(chacres)开启,愿你的第三只眼在直视真理时永不致盲!取此魔法数字,从中减去它的一个数位(该数位必须实际出现在该数字中),从而得到一个新的魔法数字。重复此操作,直至魔法数字变为零。在此期间,地球将伫立于三只海狸之上,而所历经的时间长度,恰好等于你执行的减法操作次数!”
显然,不同的减法操作序列可能导致操作次数各不相同。但聪明的海狸已做好直面最坏情况的准备,现请你计算:将该魔法数字减至零所需的最少操作次数。
输入格式
The single line contains the magic integer n, 0 ≤ n.
- to get 20 points, you need to solve the problem with constraints: n ≤ 106 (subproblem C1);
- to get 40 points, you need to solve the problem with constraints: n ≤ 1012 (subproblems C1+C2);
- to get 100 points, you need to solve the problem with constraints: n ≤ 1018 (subproblems C1+C2+C3).
单行输入包含魔法整数 n,其中 0 ≤ n。
- 要获得 20 分,你需要在约束条件 n ≤ 106 下解决该问题(子问题 C1);
- 要获得 40 分,你需要在约束条件 n ≤ 1012 下解决该问题(子问题 C1 + C2);
- 要获得 100 分,你需要在约束条件 n ≤ 1018 下解决该问题(子问题 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
输入解题思路,AI测评打分。不知道怎么写?