結果

問題 No.539 インクリメント
ユーザー kohei2019kohei2019
提出日時 2022-02-08 20:35:18
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 990 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 126,520 KB
最終ジャッジ日時 2023-09-05 20:58:13
合計ジャッジ時間 2,218 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,204 KB
testcase_01 AC 230 ms
126,520 KB
testcase_02 RE -
testcase_03 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
lsT = [input() for i in range(T)]

for i in range(T):
    f1 = False
    f2 = False
    t = lsT[i]
    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()
    num.reverse()
    a.reverse()
    if not num:
        print(*b,sep='')
    else:
        if num[0] == '0':
            nnum = int(''.join(num))
            nnum += 1
            c = '0'*(len(num)-len(str(nnum)))+str(nnum)
        else:
            nnum = int(''.join(num))
            nnum += 1
            c = str(nnum)
        print(''.join(a)+c+''.join(b))
        
0