TITLE: Counting the number of sets
QUESTION [5 upvotes]: Given two positive integers $n$ and $k$ with the same parity, count the number
of sets $$S = \{0 < s_1 < s_2 < \dots < s_k = n\},$$ such that $s_1, s_3, \dots$ are odd numbers, and $s_2, s_4,\dots$ are even numbers.

REPLY [2 votes]: Hint. The problem is equivalent to count the number of non-negative integer solutions of the equation
$$(2x_1+1)+(2x_2+1)+ \dots+ (2x_k+1)=n$$
that is
$$x_1+x_2+ \dots+ x_k=\frac{n-k}{2}.$$
Then $s_i=\sum_{j=1}^i(2x_j+1)$ for $i=1,2,\dots,k$. To count such solutions use Stars and bars technique.