CF138B.Digits Permutations

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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?

安德烈最喜爱的数字是 nn。他的朋友们送给他两个相同的数字 nn 作为新年礼物。他把这两个数字挂在墙上,满怀喜爱地凝视着它们。

随后,安德烈看腻了相同的数字,便开始轮流交换两个数字中的各位数字:先交换第一个数字的各位数字,再交换第二个数字的各位数字,接着再次交换第一个数字的各位数字,依此类推(每个数字中可进行任意次数的交换)。在某个时刻,他发现:若将最终得到的两个数字相加,则其和末尾所含零的个数,在所有可能的数字排列组合中达到最大值。

给定数字 nn,你能找出满足该性质的两个数字排列吗?

输入格式

The first line contains a positive integer n — the original number. The number of digits in this number does not exceed 105. The number is written without any leading zeroes.

第一行包含一个正整数 nn —— 原始数字。该数字的位数不超过 10510^5。该数字不包含前导零。

输出格式

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.

打印数字 nn 的数字的两个排列,使得这两个数的和以尽可能多的零结尾。这些排列可以有前导零(如果存在前导零,则必须全部打印出来)。这两个排列不必不同。如果有多种答案,输出任意一种即可。

输入输出样例

  • 输入#1

    198

    输出#1

    981
    819
  • 输入#2

    500

    输出#2

    500
    500

输入解题思路,AI测评打分。不知道怎么写?

首页