// yukicodr // No.49 //二次元可変配列 //vector > mass; //vector > memo; //vector memo; //#include "stdafx.h" #include #include #include //list #include //queue #include //連想コンテナ(要素が自動でソートされる)、要素1つ(Key)、keyの重複ない、O(logN) #include //連想コンテナ(要素が自動でソートされる)、要素2つ(Key,data)、keyの重複ない、dataは重複あり、O(logN) #include //hash、O(1) #include //hash、O(1) #include #include #include #include #include //#include using namespace std; #define FOR(x,to) for(x=0;x(b)?(a):(b)) #define FMIN(a,b) ((a)<(b)?(a):(b)) #define FCEIL(a,b) ((a)+(b)-1)/(b) typedef unsigned long long ULL; typedef signed long long SLL; queue _queue; string S; int ans= 0; int gflag = -1; // 0:+, 1:* int first = 1; int main() { int top = 0; cin >> S; for (int i = 0; i < S.size(); i++) { if (S[i] == '*') { string num_s = S.substr(top, i-top); top = i + 1; if (first) { ans = atoi(num_s.c_str()); first = 0; } else { if(gflag == 1) ans = ans * atoi(num_s.c_str()); else ans = ans + atoi(num_s.c_str()); } gflag = 0; } if (S[i] == '+') { string num_s = S.substr(top, i - top); top = i + 1; if (first) { ans = atoi(num_s.c_str()); first = 0; } else { if (gflag == 1) ans = ans * atoi(num_s.c_str()); else ans = ans + atoi(num_s.c_str()); } gflag = 1; } } string num_s = S.substr(top, S.size() - top); if (gflag == 1) ans = ans * atoi(num_s.c_str()); else ans = ans + atoi(num_s.c_str()); cout << ans; return 0; }