You are viewing a single comment's thread. Return to all comments →
I also did it like yours
#include <vector> #include <iostream> using namespace std; vector<int> W(37,0); int f(int n){ return W[n] ? W[n] : W[n] = n>=3 ? f(n-3)+f(n-2)+f(n-1) : (n>>1)+1; } int main() { int n;cin>>n; //ignoring s while(cin>>n and cout<<f(n)<<endl); return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Recursion: Davis' Staircase
You are viewing a single comment's thread. Return to all comments →
I also did it like yours