CSES1637 - Removing Digits

Xem dạng PDF

SUBMIT SOLUTION

ID: cses_dp_1637

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Người đăng:
Nguồn bài:
CSES - Code Submission Evaluation System
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Output Only, Pascal, PyPy, Python, Scratch, TEXT

You are given an integer ~n~. On each step, you may subtract one of the digits from the number.

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

Input Specification

  • The only input line has an integer ~n~.

Output Specification

  • Print one integer: the minimum number of steps.

Constrains

  • ~1 \le n \le 10^6~

Sample Cases

Input #1:
27
Output #1:
5
Explanation #1:
  • An optimal solution is ~27 \rightarrow 20 \rightarrow 18 \rightarrow 10 \rightarrow 9 \rightarrow 0~.

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.