結果
問題 |
No.708 (+ー)の式
|
ユーザー |
![]() |
提出日時 | 2018-06-29 23:10:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 505 bytes |
コンパイル時間 | 1,298 ms |
コンパイル使用メモリ | 159,496 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 00:12:02 |
合計ジャッジ時間 | 3,780 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 12 |
ソースコード
#include <bits/stdc++.h> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) using namespace std; typedef long long ll; string S; ll p = 0; ll dfs() { ll ret = S[p++] - '0'; while(p < S.length() || S[p] != ')') { char op = S[p++]; ll x; if(S[p] == '(') { p++; x = dfs(); p++; } else { x = S[p] - '0'; p++; } if(op == '+') ret += x; if(op == '-') ret -= x; } return ret; } int main(void) { cin >> S; cout << dfs() << endl; }