結果

問題 No.539 インクリメント
ユーザー kohei2019kohei2019
提出日時 2022-02-08 20:42:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,011 ms / 2,000 ms
コード長 1,039 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 13,244 KB
最終ジャッジ日時 2023-09-05 21:04:07
合計ジャッジ時間 3,359 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,796 KB
testcase_01 AC 350 ms
12,500 KB
testcase_02 AC 1,011 ms
13,244 KB
testcase_03 AC 988 ms
13,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

for i in range(T):
    f1 = False
    f2 = False
    t = input()
    n = len(t)
    b = []
    num = []
    a = []
    for j in range(n-1,-1,-1):
        if not f2:
            if f1 == False and t[j].isnumeric():
                num.append(t[j])
                f1 = True
            elif f1 == False and not t[j].isnumeric():
                b.append(t[j])
            elif f1 and t[j].isnumeric():
                num.append(t[j])
            else:
                a.append(t[j])
                f2 = True
        else:
            a.append(t[j])
    b.reverse()
    a.reverse()
    if not num:
        print(*b,sep='')
    else:
        c = []
        f = True
        for s in num:
            if f and s=='9':
                c.append('0')
                continue
            elif f:
                c.append(str(int(s)+1))
                f = False
            else:
                c.append(s)
        if f:
            c.append('1')
        c.reverse()
        ans = a+c+b
        print(''.join(ans))
        

0