Answer the question
In order to leave comments, you need to log in
Is the algorithm correct?
Condition:
Cross out the digit in the number so that the number remains the largest.
Let n be the number of digits in the desired number, and k=1 - how many should be crossed out.
1. We are looking for the maximum (if there are several, then we take the leftmost) digit among all the digits. Let the digit be in position i.
If i < k+1, then cross out everything on the left, print this number and solve the problem for the rest of the number (from i+2 to n).
If i = k + 1, then we cross out everything on the left, and the answer has already been received - print the resulting number.
If i > k+1, then we solve this problem for the remaining part on the left (since we cannot delete everything from there), and output the numbers [i..n].
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question