#include <bits/stdc++.h> using namespace std; int main() { string line; getline(cin,line); // 讀取整行 istringstream iss(line); stack<long long> stk; string token; while (iss>>token){ // 判斷是否為運算子或數值 if (token=="+"||token == "-"||token=="*"||token=="/"){ // C++14 以上,避免除以 0 long long b=stk.top(); stk.pop(); long long a=stk.top(); stk.pop(); long long res; if (token=="+"){ res=a+b; } else if (token=="-"){ res=a-b; } else if (token=="*"){ res=a*b; } else{ // division // 根據題意,運算結果為 32 位元有號整數,且除數不會為 0(題未說明檢查,但一般預設) res=a/b; } stk.push(res); } else { // 嘗試轉成整數 long long num=stoll(token); stk.push(num); } } // 最終堆疊中剩下的值即為運算結果 cout<<stk.top()<<endl; return 0; }