eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Ball Painting

Ball Painting

There are \textbf{2N} white balls on a table in two rows, making a nice \textbf{2}-by-\textbf{N} rectangle. Jon has a big paint bucket full of black paint. (Don’t ask why.) He wants to paint all the balls black, but he would like to have some math fun while doing it. (Again, don’t ask why.) First, he computed the number of different ways to paint all the balls black. In no time, he figured out that the answer is \textbf{(2N)!} and thought it was too easy. So, he introduced some rules to make the problem more interesting. \begin{itemize} \item The first ball that Jon paints can be any one of the \textbf{2N} balls. \item After that, each subsequent ball he paints must be adjacent to some black ball (that was already painted). Two balls are assumed to be adjacent if they are next to each other horizontally, vertically, or diagonally. \end{itemize} Jon was quite satisfied with the rules, so he started counting the number of ways to paint all the balls according to them. Can you write a program to find the answer faster than Jon? \InputFile The input consists of multiple test cases. Each test case consists of a single line containing an integer \textbf{N}, where \textbf{1} ≤ \textbf{N} ≤ \textbf{1000}. The input terminates with a line with \textbf{N = 0}. \OutputFile For each test case, print out a single line that contains the number of possible ways that Jon can paint all the \textbf{2N} balls according to his rules. The number can become very big, so print out the number modulo \textbf{1000000007}.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1
2
3
0
Вихідні дані #1
2
24
480
Джерело 2011 Stanford Local ACM Programming Contest, Saturday, October 8th, 2011