Given two matrices A and B of order p x q (or q X p) and r x s ( or s X r). The task is to find the minimum number of elements to be added to any of the two matrices to make them multiplicative.
Two matrices are multiplicative if the number of columns in one matrix is equal to the number of rows in the other matrix.
Input: p = 2, q = 3, r = 5, s = 6
Two columns can be added to make q = 5.
To add two columns, the number of elements will be added 2 * no. of rows i.e. 2 * 2 = 4
Input: p = 11, q = 5, r = 10, s = 11
- If the number of columns in one matrix is equal to the number of rows in the other matrix, then no extra elements are required to be added.
- If they are not equal, we have to add either some extra columns in one matrix or some extra rows in the other matrix.
So, calculate the number of extra elements in both condition and print the minimum one.
Below is the implementation of the above approach:
- Minimum value to be added to X such that it is at least Y percent of N
- Count of matrices (of different orders) with given number of elements
- Print elements that can be added to form a given sum
- Minimum number of Parentheses to be added to make it valid
- Minimum difference between adjacent elements of array which contain elements from each row of a matrix
- Sum of minimum elements of all possible sub-arrays of an array
- Find the first, second and third minimum elements in an array
- Sum of all minimum frequency elements in Matrix
- Minimum value to be assigned to the elements so that sum becomes greater than initial sum
- Minimum product in a grid of adjacent elements
- Program to print N minimum elements from list of integers
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- Minimum operations required to set all elements of binary matrix
- XOR of XORs of all sub-matrices
- Different Operations on Matrices
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.