CSES - Jumping

You are playing a game with n levels. Initially you are at level 0 and your goal is to reach level n. In each step, you can jump a or b levels up. How many ways are there to reach the level n?

For example, when n=4, a=1 and b=2, there are 5 ways:

  • 0 \rightarrow 1 \rightarrow 2 \rightarrow 3 \rightarrow 4
  • 0 \rightarrow 1 \rightarrow 2 \rightarrow 4
  • 0 \rightarrow 1 \rightarrow 3 \rightarrow 4
  • 0 \rightarrow 2 \rightarrow 3 \rightarrow 4
  • 0 \rightarrow 2 \rightarrow 4

You may assume that 3 \le n \le 50 and 1 \le a < b \le n.

In a file jumping.py, implement a function count that returns the answer.

def count(n,a,b):
    # TODO

if __name__ == "__main__":
    print(count(4,1,2)) # 5
    print(count(10,2,5)) # 2
    print(count(10,6,7)) # 0
    print(count(30,3,5)) # 58
    print(count(50,2,3)) # 525456