P10985 [Lanqiao Cup 2023 National Python A/Java A] Integer Transformation
Background
Python contestants are advised to submit this problem using PyPy3.
Description
Xiao Lan has an integer $n$. Every minute, Xiao Lan's number changes to the number from the previous minute minus the sum of its digits.
For example, if Xiao Lan's number starts as $23$, then the next minute it becomes $23 - (2 + 3) = 18$. The minute after that it becomes $18 - (1 + 8) = 9$. The minute after that it becomes $9 - 9 = 0$. In total, it takes $3$ minutes to become $0$.
Given a positive integer, find how many minutes it will take for this number to become $0$.
Input Format
Input one line containing an integer $n$.
Output Format
Output one integer, which is the answer.
Explanation/Hint
For $30\%$ of the test cases, $1 \le n \le 1000$.
For $60\%$ of the test cases, $1 \le n \le 10^6$.
For all test cases, $1 \le n \le 10^9$.
Translated by ChatGPT 5