7059.Removing Digits II

Time Limit: 1s Memory Limit: 512MB

You are given an integer $n$ . On each step, you may subtract from it any one-digit number that appears in it.

How many steps are required to make the number equal to $0$ ?

Input Format(From the terminal/stdin)

The only input line has an integer $n$ .

  • $1 \le n \le 10^{18}$

Output Format(To the terminal/stdout)

Print one integer: the minimum number of steps.

Sample Input

Copy
27
  \n

Sample Output

Copy
5
 \n

An optimal solution is $27 \rightarrow 20 \rightarrow 18 \rightarrow 10 \rightarrow 9 \rightarrow 0$ .

Source: CSES, Additional Problems II, 2174

Submit

请先 登录

© 2025 FAQs