Count the number of sequences that $|a_i - a_{i + 1}| \leq K \forall i = 1, 2, …, n - 1 $.

41 Views Asked by At

A sequence $a_1, a_2, …, a_n$ called superseq length n if:

$a_1 = 0$

$a_n = H$

$|a_i - a_{i + 1}|≤K∀i = 1, 2, …, n - 1$

$0≤a_i≤H∀i = 1, 2, …, n$

Given $n, H, K (K \leq H)$ count the number of superseq length $n$

How to find the recursion formula of this problem? And which variable we use for that formula?

I think it is $n$
If $n=2$, $S_n = 1, 2$ if $K=H$ or not