Random Walk That Never Goes Negative
Time limit2sMemory limit64 MB
Count length-2N walks from 0 back to 0 with steps of plus or minus 1 that never drop below 0, modulo 1,000,000,007.
- Level
Medium5 of 10
- Topics
- Combinatorics, Math
- Solved
- No attempts yet
Problem
Seonyeong stands at the origin of a very long line. In one move she can step one square to the left or one square to the right.
The number of random walks that use moves and end at the starting square is . Coming back to the start forces the number of left moves to equal the number of right moves, so the walk makes moves right and moves left, and only their order is free.
In that version Seonyeong can stand on a negative coordinate. Write a program that counts the walks once the extra rule "never move to a negative coordinate" is added. For she can walk , but she cannot walk .
Input
The first line contains the number of test cases (). Each of the next lines contains the value () of one test case.
Output
For each test case, print the number of random walks that return to the starting square without ever visiting a negative coordinate, modulo 1,000,000,007. Print one answer per line.