10029_AFamousStoneCollector

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

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

Pro.ID

10029

Title

A Famous Stone Collector

Title链接

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

AC

4

Submit

4

Ratio

100.00%

时间&空间限制

  • Time Limit: 20000/10000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Mr. B loves to play with colorful stones. There are n colors of stones in his collection. Two stones with the same color are indistinguishable. Mr. B would like to select some stones and arrange them in line to form a beautiful pattern. After several arrangements he finds it very hard for him to enumerate all the patterns. So he asks you to write a program to count the number of different possible patterns.

    Two patterns are considered different, if and only if they have different number of stones or have different colors on at least one position.

    输入

    Each test case starts with a line containing an integer n indicating the kinds of stones Mr. B have. Following this is a line containing n integers --- the number of available stones of each color respectively. All the input numbers will be nonnegative and no more than 100.

    输出

    Description

    Mr. B loves to play with colorful stones. There are n colors of stones in his collection. Two stones with the same color are indistinguishable. Mr. B would like to select some stones and arrange them in line to form a beautiful pattern. After several arrangements he finds it very hard for him to enumerate all the patterns. So he asks you to write a program to count the number of different possible patterns.

    Two patterns are considered different, if and only if they have different number of stones or have different colors on at least one position.

    Input

    Each test case starts with a line containing an integer n indicating the kinds of stones Mr. B have. Following this is a line containing n integers --- the number of available stones of each color respectively. All the input numbers will be nonnegative and no more than 100.

    Output

    For each test case, display a single line containing the case number and the number of different patterns Mr. B can make with these stones, modulo 1,000,000,007, which is a prime number.

    Sample Input

    3
    1 1 1
    2
    1 2

    Sample Output

    Case 1: 15
    Case 2: 8

    Hint

    In the first case, suppose the colors of the stones Mr. B has are B, G and M, the different patterns Mr. B can form are: B; G; M; BG; BM; GM; GB; MB; MG; BGM; BMG; GBM; GMB; MBG; MGB.

    Source

    样例输入

    3
    1 1 1
    2
    1 2

    样例输出

    Case 1: 15
    Case 2: 8

    提示

    In the first case, suppose the colors of the stones Mr. B has are B, G and M, the different patterns Mr. B can form are: B; G; M; BG; BM; GM; GB; MB; MG; BGM; BMG; GBM; GMB; MBG; MGB.


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部