結果

問題 No.3658 Darumaka Number 2
コンテスト
ユーザー wasd314
提出日時 2026-08-30 13:44:25
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 237 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 79,360 KB
最終ジャッジ日時 2026-08-30 13:44:32
合計ジャッジ時間 6,119 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
    ns = input()
    trs = str.maketrans("0123456789", "0000455555")
    ns = ns.translate(trs)
    if ns[0] == "0":
        return "5" * (len(ns) - 1)
    if "0" not in ns:
        return ns
    i = ns.index("0")
    s = ns[:i]
    r = "5" * (len(ns) - i)
    if "5" not in s:
        return "4" * (i - 1) + r
    j = s.rindex("5")
    return s[:j] + "4" + "5" * (len(s) - j - 1) + r


case_t = 1
# case_t = int(input())
for _ in [None] * case_t:
    print(solve())
0