結果

問題 No.708 (+ー)の式
ユーザー MineMine
提出日時 2020-09-15 23:42:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 698 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 7,880 KB
最終ジャッジ日時 2023-09-04 03:09:19
合計ジャッジ時間 1,479 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,788 KB
testcase_01 AC 17 ms
7,800 KB
testcase_02 AC 17 ms
7,804 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 17 ms
7,880 KB
testcase_05 AC 16 ms
7,796 KB
testcase_06 AC 16 ms
7,804 KB
testcase_07 AC 16 ms
7,812 KB
testcase_08 AC 17 ms
7,752 KB
testcase_09 AC 16 ms
7,760 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 16 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
    
0