結果
| 問題 |
No.3308 One-time Changed Formula
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-10-24 21:55:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 261 ms / 2,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 246 ms |
| コンパイル使用メモリ | 82,416 KB |
| 実行使用メモリ | 120,004 KB |
| 最終ジャッジ日時 | 2025-10-24 21:55:54 |
| 合計ジャッジ時間 | 3,783 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 |
ソースコード
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.append(f)
if f in ["+","-","*"]:
num.append("".join(tmp))
tmp=[]
ope.append(f)
num.append("".join(tmp))
ans=0
p=1
for i in range(len(num)):
if p:
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)