Retired

Jump to zero (Subtask 3) (retired)

Description:

You are given a positive integer n. For every operation, subtract n by the sum of its digits. Count the number of operations to make n = 0.

For example, with n = 20, you have to use 3 operations. Firstly, n = 20 - (2 + 0) = 18. Secondly, n = 18 - (1 + 8) = 9. Finally, n = 9 - 9 = 0.

You have to answer q such questions.

You can get the original, Vietnamese statement here: https://tleoj.edu.vn/problem/24e

Some subtasks in the original problem have been rewritten to be suitable with Python language

In this subtask, q <= 1 000, n <= 10 ** 5

You can solve each subtask in independent katas:

You have to write a function named jump_to_zero() which receives an array (of q positive intergers) and returns an array (of q positive intergers).

Example:

  • Input: [18, 19, 20]
  • Output: [2, 2, 3]

There are 201 testcases in the test kit, include:

  • Example test (1 test): [18, 19, 20]
  • Subtask 2 (100 tests): n <= 10 ** 5
  • Subtask 3 (100 tests): n <= 10 ** 6

From TLEoj team with love <3

Mathematics
Algorithms
Dynamic Programming
Number Theory
Performance

Stats:

CreatedAug 6, 2023
Warriors Trained41
Total Skips0
Total Code Submissions24
Total Times Completed11
Python Completions11
Total Stars1
% of votes with a positive feedback rating42% of 6
Total "Very Satisfied" Votes2
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes3
Total Rank Assessments7
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • TLEojxSunlight Avatar
Ad