結果

問題 No.39 桁の数字を入れ替え
ユーザー matsu7874matsu7874
提出日時 2015-10-26 10:37:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 8,288 KB
最終ジャッジ日時 2023-10-11 10:14:03
合計ジャッジ時間 1,363 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,848 KB
testcase_01 AC 16 ms
8,280 KB
testcase_02 AC 17 ms
7,904 KB
testcase_03 WA -
testcase_04 AC 17 ms
8,284 KB
testcase_05 AC 16 ms
8,100 KB
testcase_06 AC 16 ms
8,224 KB
testcase_07 AC 16 ms
8,152 KB
testcase_08 AC 16 ms
7,912 KB
testcase_09 AC 16 ms
7,948 KB
testcase_10 AC 16 ms
8,288 KB
testcase_11 AC 16 ms
8,076 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())


def each_digits(n, base=10):
    # 各桁の数字を得る
    digits = []
    a = 1
    while n >= a:
        digits.append(n // a % base)
        a *= base
    return digits[::-1]
n = each_digits(N)
l = len(n)
for i in range(l - 1):
    ma = max(n[i + 1:])
    if ma > n[i]:
        for j in range(l):
            if n[l - 1 - j] == ma:
                n[i], n[l - 1 - j] = n[l - 1 - j], n[i]
            answer = 0
            for a in n:
                answer *= 10
                answer += a
            print(answer)
            exit()
print(N)
0