結果
問題 |
No.708 (+ー)の式
|
ユーザー |
![]() |
提出日時 | 2018-06-29 23:09:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 505 bytes |
コンパイル時間 | 1,273 ms |
コンパイル使用メモリ | 158,856 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-01 00:11:49 |
合計ジャッジ時間 | 1,885 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 2 |
ソースコード
#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; }