21266_TreeCoun

2022-5-16 18:19| 发布者: Hocassian| 查看: 46| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-8950578950800-Problem List-采集的数据-后羿采集器.html

Pro.ID

21266

Title

Tree Count

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21266

AC

1

Submit

1

Ratio

100.00%

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    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 −1.


    输入

    Input will be formatted as follows. Each test case will occur on its own line. Each line will contain only a single integer, N, the number of nodes. The value of N will be between 1 and 1427, inclusive.

    输出

    Description
    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 −1.


    Input
    Input will be formatted as follows. Each test case will occur on its own line. Each line will contain only a single integer, N, the number of nodes. The value of N will be between 1 and 1427, inclusive.
    Output
    Your output is one line per test case, containing only the nine-digit code (note that you must print leading zeros).
    Sample Input
    1
    3
    6
    21
    Sample Output
    000000001
    000000001
    000000004
    000036900
    Source

    样例输入

    1
    3
    6
    21

    样例输出

    000000001
    000000001
    000000004
    000036900

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部