CF102B.Sum of Digits

普及/提高-

通过率:0%

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 nn . How many times can Gerald put a spell on it until the number becomes one-digit?

输入格式

The first line contains the only integer nn ( 0<=n<=101000000<=n<=10^{100000} ). It is guaranteed that nn doesn't contain any leading zeroes.

输出格式

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 1010 . After one casting of a spell it becomes 11 , and here the process is completed. Thus, Gerald can only cast the spell once.

The third test contains number 991991 . As one casts a spell the following transformations take place: 99119101991→19→10→1 . After three transformations the number becomes one-digit.

首页