結果
問題 | No.708 (+ー)の式 |
ユーザー |
![]() |
提出日時 | 2018-06-29 22:56:29 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 476 bytes |
コンパイル時間 | 84 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-01 00:07:09 |
合計ジャッジ時間 | 1,222 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
s_0 = list(input())def calc(s):N = len(s)ans = int(s[0])num = Falseplus = Truefor i in range(1,N):if num:if plus:ans += int(s[i])else:ans -= int(s[i])num = Falseelse:if s[i] == '+':plus = Trueelse:plus = Falsenum = Truereturn answhile '(' in s_0:left = s_0.index('(')right = s_0.index(')')s_dush = s_0[left+1:right]ans = calc(s_dush)s_0 = s_0[:left] + [str(ans)] + s_0[right+1:]print(calc(s_0))