21271_Pills

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

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

Pro.ID

21271

Title

Pills

Title链接

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

AC

3

Submit

5

Ratio

60.00%

时间&空间限制

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

    Aunt Lizzie takes half a pill of a certain medicine every day. She starts with a bottle that contains 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 2N days as a string, where the i-th character is W if a whole pill was chosen on the i-th day, and H if a half pill was chosen (0 ≤ i < 2N). How many different valid strings are there that empty the bottle?

    输入

    The input will contain data for at most 1000 problem instances. For each problem instance there will be one line of input: a positive integer N ≤ 30, the number of pills initially in the bottle. End of input will be indicated by 0.

    输出

    Description

    Aunt Lizzie takes half a pill of a certain medicine every day. She starts with a bottle that contains 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 2N days as a string, where the i-th character is W if a whole pill was chosen on the i-th day, and H if a half pill was chosen (0 ≤ i < 2N). How many different valid strings are there that empty the bottle?

    Input

    The input will contain data for at most 1000 problem instances. For each problem instance there will be one line of input: a positive integer N ≤ 30, the number of pills initially in the bottle. End of input will be indicated by 0.

    Output

    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.

    Sample Input

    6
    1
    4
    2
    3
    30
    0

    Sample Output

    132
    1
    14
    2
    5
    3814986502092304

    Source

    样例输入

    6
    1
    4
    2
    3
    30
    0

    样例输出

    132
    1
    14
    2
    5
    3814986502092304

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部