結果

問題 No.39 桁の数字を入れ替え
ユーザー けむけむけむけむ
提出日時 2021-07-09 16:44:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 644 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2023-09-14 06:31:18
合計ジャッジ時間 1,523 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 16 ms
7,840 KB
testcase_02 RE -
testcase_03 AC 16 ms
7,812 KB
testcase_04 AC 16 ms
7,848 KB
testcase_05 AC 16 ms
7,716 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 16 ms
7,728 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 16 ms
7,756 KB
testcase_11 AC 16 ms
7,752 KB
testcase_12 AC 16 ms
7,756 KB
testcase_13 AC 16 ms
7,796 KB
testcase_14 AC 17 ms
7,888 KB
testcase_15 AC 16 ms
7,816 KB
testcase_16 AC 16 ms
7,936 KB
testcase_17 AC 17 ms
7,924 KB
testcase_18 AC 16 ms
7,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def change(N):
    N_li = list(str(N))
    for i in range(len(N_li)):
        N_li[i] = int(N_li[i])
    n_max = max(N_li)
    if N_li[0] == n_max:
        s = ''
        for k in range(1, len(N_li)):
            s += str(N_li[k])
        N2 = change(int(s))
        s2 = str(n_max) + str(N2)
        return int(s2)
    for j in range(1, len(N_li) + 1):
        if N_li[-j] == n_max:
            N_li[-j] = 0 + N_li[0]
            N_li[0] = n_max
            break
    s = ''
    for k in range(len(N_li)):
        s += str(N_li[k])
    return int(s)

def main():
    N = int(input())
    print(change(N))

if __name__ == '__main__':
    main()
0