300728: CF138B. Digits Permutations

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Digits Permutations

题意翻译

给定一个数 $n$,要求求出这个数的两个排列使这两个排列相加的末尾有最多的 $0$。

题目描述

Andrey's favourite number is $ n $ . Andrey's friends gave him two identical numbers $ n $ as a New Year present. He hung them on a wall and watched them adoringly. Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so on (arbitrary number of changes could be made in each number). At some point it turned out that if we sum the resulting numbers, then the number of zeroes with which the sum will end would be maximum among the possible variants of digit permutations in those numbers. Given number $ n $ , can you find the two digit permutations that have this property?

输入输出格式

输入格式


The first line contains a positive integer $ n $ — the original number. The number of digits in this number does not exceed $ 10^{5} $ . The number is written without any leading zeroes.

输出格式


Print two permutations of digits of number $ n $ , such that the sum of these numbers ends with the maximum number of zeroes. The permutations can have leading zeroes (if they are present, they all should be printed). The permutations do not have to be different. If there are several answers, print any of them.

输入输出样例

输入样例 #1

198

输出样例 #1

981
819

输入样例 #2

500

输出样例 #2

500
500

Input

题意翻译

给定一个数 $n$,要求求出这个数的两个排列使这两个排列相加的末尾有最多的 $0$。

加入题单

算法标签: