結果

問題 No.539 インクリメント
ユーザー ThetaTheta
提出日時 2022-11-24 18:41:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 734 bytes
コンパイル時間 146 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-08 15:53:06
合計ジャッジ時間 1,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,984 KB
testcase_01 AC 49 ms
10,368 KB
testcase_02 RE -
testcase_03 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from re import findall, finditer, compile


def main():
    for _ in range(int(input())):
        S = input()
        S = S[::-1]
        prog = compile(r"\d+")

        result = prog.search(S)
        if result is None:
            print(S[::-1])
            continue

        length = len(result.group())
        lv_up = int(result.group()[::-1]) + 1
        if len(str(lv_up)) >= length:
            print((S[:result.start()] + str(lv_up)
                  [::-1] + S[result.end():])[::-1])
        else:
            print((S[:result.start()] + ("{:0"+str(length)+"d}").format(lv_up,
                                                                        )[::-1] + S[result.end():])[::-1])


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