We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
When m == 1, then you have to return pow(2, n, 1e9 + 7), since the recurrent relationship F(m, n) = 2F(m, n - 1) - F(m, n - 2) + F(m, n - m - 1) degenerates into F(m, n) = 2F(m, n - 1).
We take F(1, 1) = 1, so F(m, n) = pow(2, n)
I hope this helps :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #114: Counting block combinations I
You are viewing a single comment's thread. Return to all comments →
When m == 1, then you have to return pow(2, n, 1e9 + 7), since the recurrent relationship F(m, n) = 2F(m, n - 1) - F(m, n - 2) + F(m, n - m - 1) degenerates into F(m, n) = 2F(m, n - 1). We take F(1, 1) = 1, so F(m, n) = pow(2, n) I hope this helps :)