#P5456. 4D Cake Slicing
4D Cake Slicing
4D Cake Slicing
Feifei recently learned how to bake cakes. She made a 4D cake of size \(a \times b \times c \times d\) and gave it to Niuniu. All the surfaces of the cake are frosted with cream. Niuniu plans to cut the cake along hyperplanes parallel to the surfaces to obtain \(1 \times 1 \times 1 \times 1\) small hypercubes.
Because the cake is 4-dimensional, its boundary consists of 8 hyperfaces. However, note that if a cake dimension equals 1, then the only small block in that dimension touches both corresponding frosting surfaces (i.e. it gains 2 iced faces in that dimension). For any dimension with length greater than 1, a small block gets cream on that dimension if and only if its coordinate is either 1 or the dimension length (adding 1 iced face for that dimension).
Your task is to calculate the number of small blocks that have exactly \(0, 1, 2, \dots, 8\) frosted faces.
Explanation:
Let the four dimensions be \(a\), \(b\), \(c\), and \(d\). For each dimension:
- If the dimension equals 1, then the block in that dimension automatically gets 2 iced faces.
- If the dimension is greater than 1, a block can either be on a boundary (ice count = 1, with 2 ways to be at a boundary) or in the interior (ice count = 0, with \(L-2\) ways, where \(L\) is the length in that dimension).
The overall iced face count for a block is the sum over the 4 dimensions. Note that only some totals (between 0 and 8) are possible depending on the input.
inputFormat
The input consists of a single line containing four integers \(a\), \(b\), \(c\), \(d\) separated by spaces.
outputFormat
Output 9 space‐separated integers indicating the number of small 4D blocks that have exactly \(0, 1, 2, \dots, 8\) iced faces respectively.
sample
1 1 1 1
0 0 0 0 0 0 0 0 1