#include <string>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param tokens string字符串vector 
     * @return int整型
     */
    int evalRPN(vector<string>& tokens) {
        // write code here
        stack<int> st;
        int num1, num2;
        for (string & i : tokens)
        {
            if ((i != "+") && (i != "-") && (i != "*") && (i != "/"))
            {
                st.push(std::stoi(i));
            }
            else if (!st.empty())
            {
                num1 = st.top();
                st.pop();
                num2 = st.top();
                st.pop();
                if (i == "+")
                    st.push(num1 + num2);
                else if (i == "-")
                    st.push(num2 - num1);
                else if (i == "*")
                    st.push(num1 * num2);
                else if (i == "/")
                    st.push(num2 / num1);
            }
        }
        return st.top();
    }
};