#P5784. [CQOI2008] 矩阵的个数

[CQOI2008] 矩阵的个数

Description

Given the sums of each row and each column of an n×3n \times 3 non-negative integer matrix, count how many matrices satisfy these conditions. Output the answer modulo 101710^{17}.

Input Format

The first line contains four positive integers NN, c1c_1, c2c_2, c3c_3, representing the number of rows and the sums of the three columns. The second line contains NN positive integers, representing the sum of the three numbers in each row. The sum of each row and each column does not exceed 125125.

Output Format

Output one number: the number of matrices satisfying the conditions modulo 101710^{17}.

3 2 3 4
1 2 6

17

Hint

Test Point ID 1 2 3 4 5 6 7 8 9 10
NN 11 22 33 1010 3030 5050 8080 120120 150150 200200

Translated by ChatGPT 5