Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. bfs.
rgb2gray
Question: Given 3 two dimensional matrixes, the task is to calculate the average matrix of three matrixes.
Each matrix has different coefficients. The first matrix has coefficients 0.30, second matrix 0.58 and the coefficients for the third matrix is 0.12.
Input specification: In the first line you will be given the dimensions of matrixes (1<=m,n<=350) then in the following lines there are three matrixes size of m by n. Where each element of matrixes is: 1<=element<=100.
Output specification: Show the integer average matrix.
Sample Input I
3 4 42 98 87 63 15 73 94 60 97 89 12 98 93 15 29 58 71 87 16 85 17 79 31 79 32 32 5 12 47 94 63 3 73 69 17 2
|
Sample Output I
70 42 44 54 51 84 45 68 48 81 24 75
|
Sample Input I Explanation
The first element (0,0) of average matrix is calculatin in this way:
avg[0][0]=A[0][0]*0.30 + B[0][0]*0.58 + C[0][0]*0.12
=42*0.30 + 93*0.58 + 32*0.12
= 70.38
The nearest integer of 70.38 is 70.
Note: use rand() function to calculate nearest integer of a number. Для отправки решений необходимо выполнить вход.
|