// yukicodr // No.49 //二次元可変配列 //vector <vector <int>> mass; //vector <vector <int>> memo; //vector <int> memo; //#include "stdafx.h" #include <iostream> #include <vector> #include <list>//list #include <queue> //queue #include <set> //連想コンテナ(要素が自動でソートされる)、要素1つ(Key)、keyの重複ない、O(logN) #include <map> //連想コンテナ(要素が自動でソートされる)、要素2つ(Key,data)、keyの重複ない、dataは重複あり、O(logN) #include <unordered_set> //hash、O(1) #include <unordered_map> //hash、O(1) #include <algorithm> #include <iomanip> #include <cstring> #include <string> #include <climits> //#include <bits/stdc++.h> using namespace std; #define FOR(x,to) for(x=0;x<to;x++) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define FMAX(a,b) ((a)>(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<int> _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; }