eolymp
bolt
Try our new interface for solving problems
Məsələlər

Random Walks

Random Walks

"Thorfun Company Limited" aka "thorfun.com", a social network for blogger, writer and reader, founded by four new graduated. One of them is passion in computational problems. One day he found something very interesting because, it is a solution of various problems and “Random Walks” is one of them. Given a one dimensional line and you stand at the original point (position 0). At each step you can walk either left or right for unit length. \includegraphics{https://static.e-olymp.com/content/da/da6e961af45507d40e49619c48fd06014406c670.jpg} First, let us have a look at a basic version of the problem. You can walk whatever you want for \textbf{2N} steps but, you must end at the original point. How many different paths that you can walk? The solution is very simple. You start and end at the same point, it means that you must take the same number of left and right step. Choosing \textbf{N} for the right and the other \textbf{N} for the left from \textbf{2N} steps is equal to . "Random Walks" problem is similar to the basic problem. However, during the walks you must not walk into negative integers. For example, if \textbf{N = 1} you can walk on the path \textbf{0}→\textbf{1}→\textbf{0} but you can’t walk on path \textbf{0}→\textbf{-1}→\textbf{0}. You task is to write a program to compute the number of path that follow the above rules. In addition, the result may be very large. So, print the result modulo by \textbf{1000000007} (Prime number). \InputFile First line of input is a number of test cases \textbf{T} ≤ \textbf{1000}. Each test case is a line contain an integers \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{1000000}). \OutputFile For each test case, display an integer indicating the number of paths that you can walk modulo by \textbf{1000000007}.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
3
1
3
6
Çıxış verilənləri #1
1
5
132
Mənbə ACM ICPC Asia Thailand National programming Contest 2013