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

Diagrams & Tableaux

Diagrams & Tableaux

A Young diagram is an arrangement of boxes in rows and columns conforming to the following rules: \begin{itemize} \item the boxes in each row and each column are contiguous, \item the left borders of all rows are aligned, and \item each row is not longer than the one above. \end{itemize} Here are some examples of Young diagrams: \includegraphics{https://static.e-olymp.com/content/db/db719184c07146100dcc105c682faeac11ab8130.jpg} A semi-standard Young tableau for a given number \textbf{N} is a Young diagram that has its boxes filled according to the following rules: \begin{itemize} \item Each box contains a single integer between \textbf{1} and \textbf{N}, inclusive, \item each integer is greater than or equal to the integer in the box to its left, and \item each integer is strictly greater than the integer in the box above. \end{itemize} Here is a list of all semi-standard Young tableaux for \textbf{N = 3}, based on a particular Young diagram: \includegraphics{https://static.e-olymp.com/content/5e/5e708087219e9eeac84b698500fa71d0152cc455.jpg} Your task is to count how many semi-standard Young tableaux are possible, based on a given Young diagram, with a given \textbf{N}. \InputFile Each test case consists of two lines. The first line of each test case specifies the Young diagram. This line starts with the number \textbf{k} satisfying \textbf{1} ≤ \textbf{k} ≤ \textbf{7}, the number of rows, followed by \textbf{k} positive integers \textbf{l_1}, \textbf{l_2}, ..., \textbf{l_k}. These integers specify the number of boxes on each row of the Young diagram, and they satisfy \textbf{7} ≥ \textbf{l_1} ≥ \textbf{l_2} ≥ ... ≥ \textbf{l_k} ≥ \textbf{1}. The second line contains the integer \textbf{N}, satisfying \textbf{k} ≤ \textbf{N} ≤ \textbf{7}. \OutputFile For each test case, print one line containing the number of semi-standard Young tableaux based on the given Young diagram, with the given \textbf{N}.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1 1
1
1 1
2
2 2 1
4
4 3 2 1 1
4
Вихідні дані #1
1
2
20
20
Джерело ACM ICPC NWERC 2013