結果

問題 No.708 (+ー)の式
ユーザー 佐藤篤樹
提出日時 2021-10-12 18:27:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,757 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 115,012 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 05:12:44
合計ジャッジ時間 1,513 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>
#include <iomanip>
#include <time.h>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <array>
using namespace std;
typedef long long ll;
typedef long double dd;
typedef vector<ll> vl;
typedef vector<dd> vd;
typedef vector<vector<ll>> vvl;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
ll c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
dd EPS=1E-6;
dd PI=acos(-1);
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll exp1(string &s, ll &i);
ll exp2(string &s, ll &i);
ll exp1(string &s, ll &i){
ll res = 0;
while(i<s.size() && s[i] != ')'){
if(s[i] == '+'){
i++;
res += exp2(s, i);
}else if(s[i] == '-'){
i++;
res -= exp2(s, i);
}else{
res += exp2(s, i);
}
}
if(s[i] == ')')i++;
return res;
}
ll exp2(string &s, ll &i){
if(s[i] == '('){
i++;
ll res = exp1(s, i);
return res;
}else{
ll res = s[i] - '0';
i++;
return res;
}
}
signed main(){fastio
string s;cin>>s;
ll i = 0;
cout<<exp1(s, i)<<endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0