Блог пользователя Black_hat123

Автор Black_hat123, история, 5 лет назад, По-английски

Can anybody please tell how to solve This problem..

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Notice that the problem is asking you to find the solution to the following problem:

f(N) = f(N-a) + f(N-b), where f(0) = 1

Since N can be quite large, you cannot simply solve bottom up, as this would be O(N). The correct approach is to utilize matrix exponentiation to solve recurrence relations. I recommend a google search for doing this with a simple recurrence relation to start, fibonacci. After that, you will see that this is easily solved in a similar way.