CF670F.Restore a Number
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k — the number of digits in n.
Magically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remembers, is a non-empty substring of n (a substring of n is a sequence of consecutive digits of the number n).
Vasya knows that there may be more than one way to restore the number n. Your task is to find the smallest possible initial integer n. Note that decimal representation of number n contained no leading zeroes, except the case the integer n was equal to zero itself (in this case a single digit 0 was used).
瓦西娅决定将一个非常大的整数 n 告诉凯特。他首先将该数写成字符串形式,然后在其右侧追加整数 k —— 即 n 的位数。
神奇的是,在这张纸条传递给凯特的过程中,所有数字被以任意顺序打乱了。瓦西娅唯一还记得的,是 n 的一个非空子串(即 n 中连续的一段数字)。
瓦西娅知道,恢复原始数字 n 的方式可能不止一种。你的任务是找出最小的可能的初始整数 n。注意:整数 n 的十进制表示中不含前导零,除非 n 本身等于 0(此时仅用单个数字 0 表示)。
输入格式
The first line of the input contains the string received by Kate. The number of digits in this string does not exceed 1 000 000.
The second line contains the substring of n which Vasya remembers. This string can contain leading zeroes.
It is guaranteed that the input data is correct, and the answer always exists.
输入的第一行包含凯特接收到的字符串。该字符串中的数字个数不超过 1000000。
第二行包含瓦夏所记得的 n 的子串。该字符串可能包含前导零。
保证输入数据合法,且答案一定存在。
输出格式
Print the smalles integer n which Vasya could pass to Kate.
输出瓦西娅可能告诉凯特的最小整数 n。
输入输出样例
输入#1
003512 021
输出#1
30021
输入#2
199966633300 63
输出#2
3036366999
输入解题思路,AI测评打分。不知道怎么写?