#P10985. [蓝桥杯 2023 国 Python A/Java A] 整数变换

[蓝桥杯 2023 国 Python A/Java A] 整数变换

Background

Python contestants are advised to submit this problem using PyPy3.

Problem Description

Xiao Lan has an integer nn. 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 2323, then the next minute it becomes 23(2+3)=1823 - (2 + 3) = 18. The minute after that it becomes 18(1+8)=918 - (1 + 8) = 9. The minute after that it becomes 99=09 - 9 = 0. In total, it takes 33 minutes to become 00.

Given a positive integer, find how many minutes it will take for this number to become 00.

Input Format

Input one line containing an integer nn.

Output Format

Output one integer, which is the answer.

23
3

Hint

For 30%30\% of the test cases, 1n10001 \le n \le 1000.

For 60%60\% of the test cases, 1n1061 \le n \le 10^6.

For all test cases, 1n1091 \le n \le 10^9.

Translated by ChatGPT 5