Matrix Rotation

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 2687
64-bit integer IO format: %I64d      Java class name: Main

Description

Give you a n*n matrix, if you rotate it 90 degrees, we call it 1-Matrix, if you rotate it 180 degrees, we call it 2-Matrix, etc … This is said if you rotate the Matrix 90*k degrees, then we call it k-Matrix. Now, your task is to calculate all the sum of i-Matrix (0<= i<= k).

Input

There multiple test cases. Each test case begins with one integer n(1 <= n <= 10), following n lines, each line contains n integers, describe the original matrix, then a single line contains a k
(1 <= k <= 10^8)described above. Process to end of file.

Output

For each case, output the sum of all the i-Matrix (0<= i<= k) in n lines.
Each line there are n integers separated by one space.
Note that there is no extra space at the end of each line.

Sample Input

3
1 2 3
2 3 4
3 4 5 
10

Sample Output

33 32 31
34 33 32
35 34 33

Source

Language: 
Theme: 
Share Code? 

Powered by NB231 | Current Style: .