GeneratingFunction Challenging

Problem - 4426

Let $n$, $m$ and $k$ be three positive integers satisfying $m(k-1) < n$. Find the number of ways to select $k$ items from $\{1,\ 2,\ \cdots,\ n\}$ for form a strict increasing sequence and the difference between adjacent terms is no more than $m$.


Let the first term be $a_1$, the second term be $(a_1+a_2)$, the third term be $(a_1+a_2+a_3)$, $\cdots$, the $k^{th}$ term be $(a_1+a_2+\cdots + a_k)$, where $a_1 \ge 1$, and every other $a_i$ satisfies $1 \le a_i \le m$.

Let $a_2+a_3+\cdots + a_k = r$. Then it must be true that $(k-1)\le r \le m(k-1)$ and $1\le r \le n-r$. The latter is because the $k^{th}$ term equals $(a_1 +r)\le n$. 

Meanwhile, the number of possible $(a_2,\ a_3,\ \cdots,\ a_k)$ selections is the coefficient of the $x_r$ term in the expanded form of $$(x+x^2+\cdots + x^{m})^{k-1}$$

or equivalently the coefficient of $x^{r-(k-1)}=x^j$ in the the expanded form of $$f(x)=(1+ x+x^2+\cdots + x^{m-1})^{k-1}=\sum_{j=0}^{(m-1)(k-1)}c_jx^j$$

Because $k-1\le r\le m(k-1)$, therefore $0\le r-(k-1)\le (m-1)(k-1)$. This means that every term $c_jx^j$ corresponds to a legitimate selection. Meanwhile, because the $1\le a_1 \le n-r$, therefore for every $r$, $a_1$ has $(n-r)$ different choices. It follows that the desired answer is (note $r=j+(k-1)$) $$\sum_{j=0}^{(m-1)(k-1)}c_j(n-(j+k-1))=(n-k+1)\sum_{j=0}^{(m-1)(k-1)}c_j -\sum_{j=0}^{(m-1)(k-1)}jc_j$$

The sum in the first term is simply the sum of all coefficients in $f(x)$ which can be obtained by setting $x=1$ in $f(x)$. Then answer is $m^{k-1}$.

The second sum can be computed using the derivative method. Taking the derivative of $f(x)$ gives $$f(x)=\sum_{j=0}^{(m-1)(k-1)}c_jx^j \implies \frac{d}{dx}f(x)=\sum_{j=1}^{(m-1)(k-1)}jc_jx^{j-1}$$

Therefore, the second sum can be computed by setting $x=1$ in $\frac{d}{dx}f(x)$. Meanwhile, $$\frac{d}{dx}f(x)=(k-1)(1+x+\cdots+x^{m-1})^{k-2}(1+2x+\cdots +(m-1)x^{m-2}$$

Setting $x=1$ leads to $$\frac{(k-1)(m-1)m^{k-1}}{2}$$

Then the final result comes as $$(n-k+1)m^{k-1}-\frac{(k-1)(m-1)m^{k-1}}{2}=\boxed{m^{k-1}\left(n-\frac{1}{2}(k-1)(m+1)\right)}$$

report an error