AtCoder Regular Contest 130
翻译中…
Problem Statement
翻译中…
Given are positive integers $a, b$, where none of the digits is $0$.
翻译中…
Permute the digits of each of $a$ and $b$ so that the sum of the digits in $a+b$ is minimized.
翻译中…
Constraints
翻译中…
$1\leq a, b< 10^{100000}$- None of the digits of
$a$and$b$is$0$.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
a
b
翻译中…
Output
翻译中…
After permuting the digits of each of $a$ and $b$ so that the sum of the digits in $a+b$ is minimized, print $a$ in the first line and $b$ in the second line.
翻译中…
If multiple solutions exist, printing any of them will be accepted.
翻译中…
样例
Input #1
253
286
Output #1
532
268
We have $532 + 268 = 800$, whole digits sum to $8+0+0=8$.
Other solutions will also be accepted, such as $(a, b) = (325, 682)$.
Input #2
345
556
Output #2
435
565
We have $435+565=1000$, whole digits sum to $1+0+0+0=1$.
Input #3
123
987987
Output #3
312
799788
We have $312 + 799788 = 800100$, whole digits sum to $8+0+0+1+0+0=9$.
Input #4
11111111111111111111
111111111111111111111111111111
Output #4
11111111111111111111
111111111111111111111111111111
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。