#P10503. 233 Matrix Computation

    ID: 12518 Type: Default 1000ms 256MiB

233 Matrix Computation

233 Matrix Computation

In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... with the same meaning. In this problem, you are given a special matrix called the 233 matrix. The first row (row 0) of the matrix is defined as follows:

$a_{0,1}=233$, $a_{0,2}=2333$, $a_{0,3}=23333$, ... i.e. in general, for any j ≥1,

$a_{0,j} = 233\text{ followed by }(j-1)\text{ copies of }3$

For all other cells with indices i,j > 0, the following recurrence holds:

$a_{i,j} = a_{i-1,j} + a_{i,j-1}$

You are given the first column of the matrix (excluding the entry at row 0) as input, i.e., values of a_{1,0}, a_{2,0}, \dots, a_{n,0}. Your task is to compute and output the value of a_{n,m}.

inputFormat

The input consists of two lines. The first line contains two positive integers n and m where n represents the number of given values for the first column (starting from row 1) and m represents the column index you need to compute.

The second line contains n space-separated integers corresponding to a_{1,0}, a_{2,0}, \dots, a_{n,0}.

outputFormat

Output a single integer, the value of a_{n,m} in the 233 matrix.

sample

1 1
100
333

</p>