Minimum number of moves

Xem dạng PDF

Gửi bài giải

Đ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

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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

What is the minimum number of moves to make the number equal to ~0~?

Input

  • The only integer ~N~ ~(0 ≤ N ≤ 10^7)~.

Output

  • The minimums number of moves.

Sample Input 1

18

Sample Output 1

3

Sample Input 2

20

Sample Output 2

4

Notes:

  • Sample ~1~: ~18 \to 18~ – ~8 = 10\to10~ – ~1 = 9\to9~ – ~9 = 0~
  • Sample ~2~: ~20\to18\to10\to9\to0~

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.