問題一覧 > 通常問題

No.708 (+-) Expression

レベル : / AI推定難易度 : 167 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 269
作問者 : ミドリムシ / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 1947 / 自分の提出
問題文最終更新日: 2026-06-25 06:23:08
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 194 (順位表) の他の問題:

Problem Statement

You are given a (+-) expression $S$.
Evaluate it.
Here, a (+-) expression is an expression that satisfies the following conditions.

・It consists only of '+', '-', '(', ')', and the digits '0' to '9'.
・'(' and ')' correspond one-to-one, and parentheses are nested at most one level deep.
 That is, '(' and ')' appear the same number of times, and after a '(', another '(' never appears before a ')' comes.
・Two or more digits never appear consecutively.
・Two or more signs never appear consecutively.

"4-(2-1)" satisfies the conditions and is therefore a (+-) expression, but "4*2-1/1", "4.2+3", "(7-(7+7))", "77+7", and "4+-3" are not. 

Input

$S$

The input consists of one line,
in which $S(1 \leq |S| \leq 100)$ representing the problem
is given.

Output

Output the result of the calculation. Insert a newline at the end.

Sample

Sample 1
Input
3+4-2
Output
5

It is a well-known fact that $3+4-2=5$.

Sample 2
Input
3-(1-1)
Output
3

It is also a well-known fact that $3-(1-1)=3$.

Sample 3
Input
1-(2-1)+(2+2)-3
Output
1

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。