#C10698. Matrix Transformation
Matrix Transformation
Matrix Transformation
You are given an N x N matrix of positive integers. Your task is to transform the matrix following these rules:
- If an element is even, divide it by 2 (i.e. \( \frac{a}{2} \)).
- If an element is odd, multiply it by 3 and then add 1 (i.e. \( 3a+1 \)).
The transformation should be applied to each element individually. Print the resulting matrix.
inputFormat
The first line contains an integer \(N\) which represents the size of the matrix. The following \(N\) lines each contain \(N\) space-separated integers representing the matrix rows.
outputFormat
Output the transformed matrix in the same format as the input, i.e., \(N\) lines with each line containing \(N\) space-separated integers. Each integer should be transformed as follows: if the integer is even then output \(\frac{a}{2}\), if odd then output \(3a+1\).
## sample3
4 7 2
9 6 3
5 8 1
2 22 1
28 3 10
16 4 4
</p>