結果

問題 No.539 インクリメント
ユーザー hedwig100hedwig100
提出日時 2020-05-25 16:20:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 14,192 KB
最終ジャッジ日時 2024-04-21 03:46:14
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 66 ms
14,192 KB
testcase_02 AC 65 ms
11,648 KB
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def solve():
    S = list(input())
    first = False
    for i in range(len(S) - 1,-1,-1):
        if 0 <= ord(S[i]) - 48 < 10:
            if 0 <= ord(S[i]) - 48 < 9:
                S[i] = chr(ord(S[i]) + 1)
                break
            else:
                S[i] = '0' 
                first = True
        else:
            if first:
                S = S[:i + 1] + ['1'] + S[i + 1:]
                break
    print(''.join(S))


T = int(input())
for _ in range(T):
    solve()
0