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

Tree Count

Tree Count

Our superhero Carry Adder has uncovered the secret method that the evil Head Crash uses to generate the entrance code to his fortress in Oakland. The code is always the number of distinct binary search trees with some number of nodes, that have a specific property. To keep this code short, he only uses the least significant nine digits. The property is that, for each node, the height of the right subtree of that node is within one of the height of the left subtree of that node. Here, the height of a subtree is the length of the longest path from the root of that subtree to any leaf of that subtree. A subtree with a single node has a height of 0, and by convention, a subtree containing no nodes is considered to have a height of \textbf{−1}. \includegraphics{https://static.e-olymp.com/content/3f/3fd5b93d2230d1496cb0c8195561a4023640c5b1.jpg} \InputFile Input will be formatted as follows. Each test case will occur on its own line. Each line will contain only a single integer, \textbf{N}, the number of nodes. The value of \textbf{N} will be between \textbf{1} and \textbf{1427}, inclusive. \OutputFile Your output is one line per test case, containing only the nine-digit code (note that you must print leading zeros).
Ліміт часу 5 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
1
3
6
21
Вихідні дані #1
000000001
000000001
000000004
000036900
Джерело ACM ICPC 2011 Pacific Northwest Region Programming Contest