Given a n x n matrix of integers and a positive integer k. The problem is to count all sub-matrices having sum divisible by the given value k.
if :
Input : mat[][] = { {5, -1, 6},
{-2, 3, 8},
{7, 4, -9} }
k = 4
Output : 6
The index range for the sub-matrices are:
(0, 0) to (0, 1)
(1, 0) to (2, 1)
(0, 0) to (2, 1)
(2, 1) to (2, 1)
(0, 1) to (1, 2)
(1, 2) to (1, 2)
Given a n x n matrix of integers and a positive integer k. The problem is to count all sub-matrices having sum divisible by the given value k. if : Input : mat[][] = { {5, -1, 6}, {-2, 3, 8}, {7, 4, -9} }
Output : 6 The index range for the sub-matrices are: (0, 0) to (0, 1) (1, 0) to (2, 1) (0, 0) to (2, 1) (2, 1) to (2, 1) (0, 1) to (1, 2) (1, 2) to (1, 2)