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

A Famous Stone Collector

A Famous Stone Collector

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. \InputFile 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 \textbf{100}. \OutputFile 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 \textbf{1000000007}, which is a prime number. \Note In the first case, suppose the colors of the stones Mr. B has are \textbf{B}, \textbf{G} and \textbf{M}, the different patterns Mr. B can form are: \textbf{B}; \textbf{G}; \textbf{M}; \textbf{BG}; \textbf{BM}; \textbf{GM}; \textbf{GB}; \textbf{MB}; \textbf{MG}; \textbf{BGM}; \textbf{BMG}; \textbf{GBM}; \textbf{GMB}; \textbf{MBG}; \textbf{MGB}.
Лимит времени 15 секунд
Лимит использования памяти 32 MiB
Входные данные #1
3
1 1 1
2
1 2
Выходные данные #1
Case 1: 15
Case 2: 8
Источник ACM ICPC Fudan Local Programming Contest 2012