#P1106. 删数问题

删数问题

Description

Input a high-precision positive integer nn (no more than 250250 digits). After removing any kk digits, the remaining digits, kept in their original left-to-right order, form a new non-negative integer. Given nn and kk, write a program to find a strategy to remove digits so that the resulting number is minimal.

Input Format

The input consists of two lines of positive integers.

The first line contains the high-precision positive integer nn.

The second line contains the positive integer kk, the number of digits to delete.

Output Format

Output a single integer: the minimal possible remaining number.

175438 
4

13

Hint

Let len(n)\operatorname{len}(n) denote the number of digits of nn, and it is guaranteed that 1k<len(n)2501 \leq k < \operatorname{len}(n) \leq 250.

Note: after deleting some digits, the remaining number may have leading zeros, but do not output leading zeros.

Translated by ChatGPT 5