You are viewing a single comment's thread. Return to all comments →
C++
int viralAdvertising(int n) { stack<int> st; st.push(0); int tmp = 5; int t = 0; for (int i = 1; i <= n; i++) { t = floor(tmp / 2) + st.top(); tmp = floor(tmp / 2) * 3; st.push(t); } return t; }
Seems like cookies are disabled on this browser, please enable them to open this website
Viral Advertising
You are viewing a single comment's thread. Return to all comments →
C++