結果
問題 |
No.708 (+ー)の式
|
ユーザー |
|
提出日時 | 2020-09-15 23:42:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 698 bytes |
コンパイル時間 | 157 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-06-22 02:52:45 |
合計ジャッジ時間 | 1,403 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 RE * 4 |
ソースコード
s = input() ans = 0 pas = -1 pm = "+" for i in range(len(s)): if s[i] == "(": a = int(s[i+1]) b = int(s[i+3]) if s[i+2] == "+": if pm == "+": ans += a+b else: ans -= a+b else: if pm == "+": ans += a-b else: ans -= a-b pas += 1 if pas == -1: if s[i] == "+": pm = "+" elif s[i] == "-": pm = "-" else: if pm == "+": ans += int(s[i]) else: ans -= int(s[i]) elif pas == 4: pas = -1 else: pas += 1 print(ans)