eolymp
bolt
Try our new interface for solving problems

Pills

Aunt Lizzie takes half a pill of a certain medicine every day. She starts with a bottle that contains \textbf{N} pills. On the first day, she removes a random pill, breaks it in two halves, takes one half and puts the other half back into the bottle. On subsequent days, she removes a random piece (which can be either a whole pill or half a pill) from the bottle. If it is half a pill, she takes it. If it is a whole pill, she takes one half and puts the other half back into the bottle. In how many ways can she empty the bottle? We represent the sequence of pills removed from the bottle in the course of \textbf{2N} days as a string, where the \textbf{i}-th character is \textbf{W} if a whole pill was chosen on the \textbf{i}-th day, and \textbf{H} if a half pill was chosen (\textbf{0} ≤ \textbf{i} < \textbf{2N}). How many different valid strings are there that empty the bottle? \InputFile The input will contain data for at most \textbf{1000} problem instances. For each problem instance there will be one line of input: a positive integer \textbf{N} ≤ \textbf{30}, the number of pills initially in the bottle. End of input will be indicated by \textbf{0}. \OutputFile For each problem instance, the output will be a single number, displayed at the beginning of a new line. It will be the number of different ways the bottle can be emptied.
Time limit 1 second
Memory limit 64 MiB
Input example #1
6
1
4
2
3
30
0
Output example #1
132
1
14
2
5
3814986502092304
Source 2011 Rocky Mountain Regional ACM Contest Information