A10440 | Restore a Number
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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).
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).
输入格式
The first line of the input contains the string received by Kate. The number of digits in this string does not exceed $1000000$ .
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.
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.
输出格式
Print the smalles integer $n$ which Vasya could pass to Kate.
输入输出样例
输入 #1
003512 021
输出 #1
30021
输入 #2
199966633300 63
输出 #2
3036366999
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted