atcoder#ABC256C. [ABC256C] Filling 3x3 array
[ABC256C] Filling 3x3 array
Score : points
Problem Statement
You are given six integers: , and . Consider writing a positive integer on each square of a grid so that all of the following conditions are satisfied:
- For , the sum of numbers written in the -th row from the top is .
- For , the sum of numbers written in the -th column from the left is .
For example, if and , then all of the following three ways satisfy the conditions. (There are other ways to satisfy the conditions.)
How many ways are there to write numbers to satisfy the conditions?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
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, should be printed.
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