問題一覧 > 通常問題

No.39 Swapping Digits

レベル : / AI推定難易度 : 147 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 542
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 36 / 自分の提出
問題文最終更新日: 2026-06-25 04:10:03
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 38 (順位表) の他の問題:

Problem Statement

You are given a number N with at least 2 and at most 9 digits.
The number N does not contain the digit 0 in any position.
Every digit is one of the digits from 1 to 9.
You may freely choose two digits
and swap them, only once.
You may also choose not to swap.
When trying to make the largest possible number,
what is that largest number?

Input

N

N is a number with at least 2 and at most 9 digits.
Each digit is one of the digits from 1 to 9.
The digit 0 does not appear in any position.

Output

Output the largest number.
Do not forget the newline.

Sample

Sample 1
Input
12
Output
21

Swapping the 1 and the 2 of 12 makes 21.

Sample 2
Input
21
Output
21

You may also choose not to swap.

Sample 3
Input
1122
Output
2121

Swapping the first 1 and the last 2
gives 2121, which is the largest number.
Only one swap is allowed.

Sample 4
Input
999999999
Output
999999999

No matter what you do, the result is always 999999999.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。