結果

問題 No.3308 One-time Changed Formula
コンテスト
ユーザー tkykwtnb
提出日時 2025-10-24 21:46:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 818 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,052 KB
実行使用メモリ 113,620 KB
最終ジャッジ日時 2025-10-24 21:47:00
合計ジャッジ時間 6,856 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11 RE * 1 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for _ in range(T):
    N=int(input())
    F=list(input())
    num=[]
    ope=[]
    tmp=""
    for f in F:
        if "1"<=f<="9":
            tmp+=f
        if f in ["+","-","*"]:
            if len(tmp):
                num.append(tmp)
                tmp=""
            if len(num)==0 and f=="-":
                tmp+=f
            else:
                ope.append(f)
    num.append(tmp)
    pass
    ans=0
    p=1
    for i in range(len(num)):
        if p*int(num[i])>0:
            for n in num[i]:
                ans+=9-int(n)
            if p==1 and i<len(ope):
                ans+=9
        else:
            for n in num[i]:
                ans+=int(n)-1
        if i<len(ope):
            if ope[i]=="+":
                p=1
            elif ope[i]=="-":
                p=0
    print(ans)
0