結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,952 KB
testcase_01 AC 16 ms
8,268 KB
testcase_02 AC 15 ms
7,788 KB
testcase_03 AC 15 ms
8,228 KB
testcase_04 AC 16 ms
8,084 KB
testcase_05 AC 15 ms
8,208 KB
testcase_06 AC 16 ms
8,152 KB
testcase_07 AC 16 ms
8,100 KB
testcase_08 WA -
testcase_09 AC 16 ms
7,900 KB
testcase_10 AC 16 ms
8,220 KB
testcase_11 AC 16 ms
8,152 KB
testcase_12 WA -
testcase_13 AC 16 ms
8,268 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, 0, -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