結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
8,076 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 16 ms
8,144 KB
testcase_05 AC 15 ms
8,228 KB
testcase_06 AC 15 ms
8,272 KB
testcase_07 AC 15 ms
8,076 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
8,256 KB
testcase_11 AC 16 ms
8,260 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()
    
0