結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,912 KB
testcase_01 AC 17 ms
8,256 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 16 ms
8,220 KB
testcase_04 AC 16 ms
8,144 KB
testcase_05 AC 16 ms
8,244 KB
testcase_06 AC 15 ms
8,100 KB
testcase_07 AC 16 ms
8,144 KB
testcase_08 AC 16 ms
7,844 KB
testcase_09 AC 16 ms
7,896 KB
testcase_10 AC 16 ms
8,100 KB
testcase_11 AC 15 ms
8,072 KB
testcase_12 WA -
testcase_13 AC 16 ms
8,088 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def each_digits(n, base=10):
    # 各桁の数字を得る
    digits = []
    a = 1
    while n >= a:
        digits.append(n // a % base)
        a *= base
    return digits[::-1]

N = int(input())
n = each_digits(N)
l = len(n)
for i in range(l - 1):
    for j in range(l - 1, i, -1):
        if n[i] < n[j]:
            n[i], n[j] = n[j], n[i]
            answer = 0
            for a in n:
                answer *= 10
                answer += a
            print(answer)
            exit()
print(N)
0