Cube Coloring
Time limit2sMemory limit128 MB
Count the cubes in an X by Y by Z box by Manhattan distance from a given cube modulo N.
- Level
Medium7 of 10
- Topics
- Combinatorics, Prefix sum, Math
- Solved
- No attempts yet
Problem
The painter Cubic makes his works out of cubes. For the current piece he stacks cubes into an rectangular box, and every pair of touching cubes shares a full face.
Stacking alone does not finish the piece. Cubic labels the position of each cube from to in the usual coordinate system and calls the cube at the origin cube. He then picks a color for every cube from its distance to the origin cube and paints it. He paints the cubes buried inside the box too, even though nobody will see them. That is his rule.
Distance here means Manhattan distance. The Manhattan distance between the cubes and is .
Cubic uses colors numbered to . A cube whose distance to the origin cube satisfies gets color .
Cubic wants to know in advance how much of each color he needs. Write a program that computes, for every color, the number of cubes painted with it.
Input
One line holds seven integers , , , , , , , separated by single spaces. , , () are the side lengths of the box. , , (, , ) are the coordinates of the origin cube. () is the number of colors.
Output
Print integers on one line, separated by single spaces. The -th integer () is the number of cubes painted with color .