問題一覧 > 通常問題

No.2159 Filling 4x4 array

レベル : / AI推定難易度 : 2775 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 216 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 15
作問者 : hotman78 / テスター : 👑 Nachia
お気に入りにしたユーザー ProblemId : 8787 / 自分の提出
問題文最終更新日: 2022-12-09 18:35:45
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Advent Calendar Contest 2022 (順位表) の他の問題:

Problem Statement

This problem is based on Filling 3x3 array, but differs from it in various respects.

You are given $8$ integers $h_1$, $h_2$, $h_3$, $h_4$, $w_1$, $w_2$, $w_3$, $w_4$. Consider writing $1$ positive integer in each cell of a $4\times4$ grid so that all of the following conditions are satisfied.

  • For $i=1,2,3,4$, the sum of the numbers written in the $i$-th row from the top is $h_i$.
  • For $j=1,2,3,4$, the sum of the numbers written in the $j$-th column from the left is $w_j$.

How many ways are there to write the numbers so that the conditions are satisfied? Since the answer can be very large, output it modulo $998244353$.

Input

$h_1\ h_2\ h_3\ h_4\ w_1\ w_2\ w_3\ w_4$
  • $4 \leq h_1, h_2, h_3, h_4, w_1, w_2, w_3, w_4 \leq 10^{9}$
  • All input values are integers.

Output

Output the number of ways to write the numbers so that the conditions are satisfied, modulo $998244353$.

Print a newline at the end.

Sample

Sample 1
Input
4 5 7 4 4 4 8 4
Output
1

The only way to write the numbers that satisfies the conditions is the following $1$ way. Therefore, output $1$.

Sample 2
Input
4 4 5 6 6 7 8 9
Output
0
Sample 3
Input
6 14 11 4 7 14 10 4
Output
120
Sample 4
Input
21 4 26 31 4 23 30 25
Output
30613
Sample 5
Input
999999999 999999999 999999999 999999999 1000000000 1000000000 999999998 999999998
Output
823817983

Output the answer modulo $998244353$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。