CF102B.Sum of Digits
入门
通过率:0%
时间限制:2.00s
内存限制:265MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Having watched the last Harry Potter film, little Gerald also decided to practice magic. He found in his father's magical book a spell that turns any number in the sum of its digits. At the moment Gerald learned that, he came across a number n. How many times can Gerald put a spell on it until the number becomes one-digit?
看完最后一部《哈利·波特》电影后,小杰拉尔德也决定练习魔法。他在父亲的魔法书中发现了一个咒语:能将任意数字变为它的各位数字之和。就在杰拉尔德学到这个咒语时,他遇到了一个数字 n。杰拉尔德最多可以对它施放多少次该咒语,直到这个数字变成一位数?
输入格式
The first line contains the only integer n (0 ≤ n ≤ 10100000). It is guaranteed that n doesn't contain any leading zeroes.
第一行包含唯一一个整数 n(0 ≤ n ≤ 10100000)。保证 n 不含前导零。
输出格式
Print the number of times a number can be replaced by the sum of its digits until it only contains one digit.
打印一个数字可以被其各位数字之和替换的次数,直到该数字仅包含一位数字为止。
输入输出样例
输入#1
0
输出#1
0
输入#2
10
输出#2
1
输入#3
991
输出#3
3
说明/提示
In the first sample the number already is one-digit — Herald can't cast a spell.
The second test contains number 10. After one casting of a spell it becomes 1, and here the process is completed. Thus, Gerald can only cast the spell once.
The third test contains number 991. As one casts a spell the following transformations take place: 991 → 19 → 10 → 1. After three transformations the number becomes one-digit.
在第一个样例中,该数字本身已是一位数——Herald 无法施放法术。
第二个测试用例包含数字 10。施放一次法术后,它变为 1,此时过程结束。因此,Gerald 只能施放一次法术。
第三个测试用例包含数字 991。每次施放法术时,依次发生如下变换:991 → 19 → 10 → 1。经过三次变换后,该数字变为一位数。
输入解题思路,AI测评打分。不知道怎么写?