#C. C - Filling 3x3 array

    传统题 1000ms 256MiB

C - Filling 3x3 array

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

C - Filling 3x3 array

Score : $300$ points

Problem Statement

You are given six integers: $h_1, h_2, h_3, w_1, w_2$, and $w_3$.
Consider writing a positive integer on each square of a $3 \times 3$ grid so that all of the following conditions are satisfied:

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

For example, if $(h_1, h_2, h_3) = (5, 13, 10)$ and $(w_1, w_2, w_3) = (6, 13, 9)$, then all of the following three ways satisfy the conditions. (There are other ways to satisfy the conditions.)

image

How many ways are there to write numbers to satisfy the conditions?

Constraints

  • $3 \leq h_1, h_2, h_3, w_1, w_2, w_3 \leq 30$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

h1h_1 h2h_2 h3h_3 w1w_1 w2w_2 w3w_3

Output

Print the number of ways to write numbers to satisfy the conditions.


3 4 6 3 3 7
1

The following is the only way to satisfy the conditions. Thus, $1$ should be printed.

image2


3 4 5 6 7 8
0

There may not be a way to satisfy the conditions.


5 13 10 6 13 9
120

20 25 30 22 29 24
30613

2024春季入门组刷题营(七)

未参加
状态
已结束
规则
IOI
题目
8
开始于
2024-4-21 13:00
结束于
2024-4-21 15:00
持续时间
2 小时
主持人
参赛人数
12