CODESPTH - Polygon Diagonals
Consider a regular polygon with N vertices labelled 1..N. In how many ways can you draw K diagonals such that no two diagonals intersect at a point strictly inside the polygon? A diagonal is a line segment joining two non adjacent vertices of the polygon.
The first line contains the number of test cases T. Each of the next T lines contain two integers N and K.
Output T lines, one corresponding to each test case. Since the answer can be really huge, output it modulo 1000003.
1 <= T <= 10000
4 <= N <= 10^9
1 <= K <= N
For the first case, there are clearly 2 ways to draw 1 diagonal - 1 to 3, or 2 to 4. (Assuming the vertices are labelled 1..N in cyclic order).
For the third case, at most 2 non-intersecting diagonals can be drawn in a 5-gon, and so the answer is 0.