class Solution {
public:
int clumsy(int N) {
stack<int> stk;
stk.push(N);
int idx = 0;
while (--N) {
switch (idx) {
case 0:
stk.top() *= N;
break;
case 1:
stk.top() /= N;
break;
case 2:
stk.push(N);
break;
case 3:
stk.push(-N);
break;
}
idx = (idx + 1) % 4;
}
int res = 0;
while (!stk.empty()) {
res += stk.top();
stk.pop();
}
return res;
}
};