Project Euler #114: Counting block combinations I

  • + 0 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 :)