結果

問題 No.3308 One-time Changed Formula
コンテスト
ユーザー 👑 ArcAki
提出日時 2025-11-07 16:10:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,608 KB
実行使用メモリ 97,872 KB
最終ジャッジ日時 2025-11-07 16:10:49
合計ジャッジ時間 3,033 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    for _ in range(int(input())):
        _ = int(input())
        s = list(input())
        f = True
        ans = 0
        for c in s:
            if c=="+":
                if f:
                    ans += 9
                f = True
            elif c=="-":
                if f:
                    ans += 9
                f = False
            elif c=="*":
                if f:
                    ans += 9
            elif f:
                ans += 9-int(c)
            else:
                ans += int(c)-1
        print(ans)


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