CSES - Removing Digits II | Loại bỏ chữ số II

View as PDF



Problem types
Allowed languages
Assembly, Awk, C, C++, Clang, Clang++, Cobol, D, Groovy, Haskell, Java, JS, Kotlin, Lua, Node JS, ObjectiveC, Output, Pascal, Perl, Prolog, Pypy, Pypy 3, Python, Scala, Scratch
Points: 2500 (p) Time limit: 1.0s Memory limit: 512M Input: stdin Output: stdout

Cho một số nguyên \(n\). Mỗi bước, bạn có thể trừ bất kỳ số có một chữ số nào xuất hiện trong đó.

Cần thực hiện mấy bước để số đó bằng \(0\)?

Input

  • Một dòng duy nhất chứa số nguyên \(n\).

Output

  • Một dòng duy nhất chứa số bước thực hiện ít nhất.

Constraints

  • \(1\leq n \leq 10^{18}\)

Example

Sample input

27

Sample output

5

Note

  • Giải thích: Cách làm tối ưu là \(27 \rightarrow 20 \rightarrow 18 \rightarrow 10 \rightarrow 9 \rightarrow 0\).

Comments

There are no comments at the moment.