Drawing a picture
Time limit2sMemory limit512 MB
Colors cycle through cells of a row-major grid; each cell area is H_i times W_j. Report the total area covered by each color.
- Level
Medium7 of 10
- Topics
- Math, Prefix sum, Combinatorics, Implementation
- Solved
- No attempts yet
Problem
Sangsu paints a picture on a grid with N rows and M columns using L colors. He paints row 1 first, then row 2, and so on through row N. Inside one row he paints column 1 first, then column 2, and so on through column M. He uses color 1, then color 2, up to color L, and after color L he goes back to color 1.
Row i has height and column j has width , so the cell in row i and column j has area .
Sangsu does not want to waste paint, so he wants to know how much of each color he needs before he starts. Compute the total area painted with each color.
Input
The first line contains N, M, and L. ()
The second line contains N positive integers , the height of each row, separated by spaces. The sum of does not exceed .
The third line contains M positive integers , the width of each column, separated by spaces. The sum of does not exceed .
Output
Print L lines. Line k contains the total area painted with color k.
Hint
The picture Sangsu paints in the first example looks like this.
