結果

問題 No.539 インクリメント
ユーザー AEnAEn
提出日時 2022-06-14 18:32:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,696 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 16,776 KB
最終ジャッジ日時 2024-04-10 13:29:15
合計ジャッジ時間 4,819 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 407 ms
12,036 KB
testcase_02 AC 1,664 ms
16,692 KB
testcase_03 AC 1,696 ms
16,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n = int(input())
    num = set([str(i) for i in range(10)])
    for i in range(n):
        S = input()
        ans = []
        f = False
        s = False
        ok = False
        for j in reversed(range(len(S))):
            if f == False and S[j] in num:
                a, b = (int(S[j])+1)//10, (int(S[j])+1)%10
                ans.append(str(b))
                s = True
                f = True
            elif s == True and S[j] in num:
                a, b = (int(S[j])+a)//10, (int(S[j])+a)%10
                ans.append(str(b))
            elif s == True:
                if a == 1:
                    ans.append('1')
                ok = True
                s = False
                ans.append(S[j])
            else:
                ans.append(S[j])
        if f == True and ok == False and a == 1:
            ans.append('1')
        print(''.join(ans)[::-1])

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