結果

問題 No.708 (+ー)の式
ユーザー mlihua09mlihua09
提出日時 2020-09-18 02:25:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 71,400 KB
最終ジャッジ日時 2023-09-04 08:17:24
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,236 KB
testcase_01 AC 78 ms
71,232 KB
testcase_02 AC 74 ms
71,124 KB
testcase_03 AC 75 ms
71,400 KB
testcase_04 AC 70 ms
71,336 KB
testcase_05 AC 72 ms
71,232 KB
testcase_06 AC 73 ms
71,364 KB
testcase_07 AC 71 ms
71,048 KB
testcase_08 AC 73 ms
71,232 KB
testcase_09 AC 71 ms
70,904 KB
testcase_10 AC 71 ms
71,212 KB
testcase_11 AC 71 ms
71,300 KB
testcase_12 AC 74 ms
71,300 KB
testcase_13 AC 71 ms
71,276 KB
testcase_14 AC 70 ms
71,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()


ans = [0, 1]

for s in S:
    
    if s == '(':
        
        ans += [0, 1]
        
    elif s == ')':
        
        a, b = ans.pop(), ans.pop()
        ans[-1] += a * b
    
    elif s == '+':
        
        ans += [1]
        
    elif s == '-':
        
        ans += [-1]
        
    else:
        a = ans.pop()
        
        ans[-1] += a * int(s)
        
print(ans[0])
0