Balance Scale
Time limit1sMemory limit256 MB
Count the orders and pan choices for placing weights 2^1 through 2^N so the left pan never outweighs the right, modulo 1e9+9.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Greedy
- Solved
- No attempts yet
Problem
Riyuna is playing with a two pan balance. There are weights, one of each weight , , , . Riyuna picks one weight that is not on the balance yet, puts it on the left pan or on the right pan, and repeats until all weights are placed. Right after each placement, the total weight on the left pan must not exceed the total weight on the right pan.
Count the ways to place the weights. Two ways are the same only when the order of the weights is the same and every weight goes on the same pan in both.
Input
The first line contains ().
Output
Print the number of ways to place the weights, modulo (), on the first line.