当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6351:Beautiful Now

题目描述
Anton has a positive integer $n$, however, it quite looks like a mess, so he wants to make it beautiful after $k$ swaps of digits.
Let the decimal representation of $n$ as $(x_1 x_2 \cdots x_m)_{10}$ satisfying that $1 \leq x_1 \leq 9$, $0 \leq x_i \leq 9$ $(2 \leq i \leq m)$, which means $n = \sum_{i = 1}^{m}{x_i 10^{m - i}}$. In each swap, Anton can select two digits $x_i$ and $x_j$ $(1 \leq i \leq j \leq m)$ and then swap them if the integer after this swap has no leading zero.
Could you please tell him the minimum integer and the maximum integer he can obtain after $k$ swaps?
输入解释
The first line contains one integer $T$, indicating the number of test cases.
Each of the following $T$ lines describes a test case and contains two space-separated integers $n$ and $k$.
$1 \leq T \leq 100$, $1 \leq n, k \leq 10^9$.
输出解释
For each test case, print in one line the minimum integer and the maximum integer which are separated by one space.
输入样例
5
12 1
213 2
998244353 1
998244353 2
998244353 3
输出样例
12 21
123 321
298944353 998544323
238944359 998544332
233944859 998544332
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6351

最后修改于 2020-10-25T23:30:33+00:00 由爬虫自动更新

共提交 3

通过率 33.33%
时间上限 内存上限
5000/2500MS(Java/Others) 262144/262144K(Java/Others)