#P1323. 删数问题

    ID: 320 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>模拟字符串贪心优先队列队列

删数问题

Description

A set is defined as follows: 11 is an element of the set; if PP is an element of the set, then 2×P+12\times P+1 and 4×P+54\times P+5 are also elements of the set.

Take the smallest kk elements from this set, concatenate them in increasing order to form a multi-digit integer. You are required to delete mm digits from this integer so that the remaining number is as large as possible. Write a program to output the integer before deletion and the integer after deletion.

Note: It is guaranteed that not all digits are deleted.

Input Format

A single line with two integers representing kk and mm.

Output Format

Output two lines. The first line is the number before deletion. The second line is the number after deletion.

5 4
137915
95

Hint

Constraints

  • For 30%30\% of the testdata, it is guaranteed that 1k,m3001 \le k, m \le 300.
  • For 100%100\% of the testdata, it is guaranteed that 1k,m3×1041 \le k, m \le 3\times 10^4.

Translated by ChatGPT 5