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 all minimum frequency elements in Matrix
- Sum of minimum elements of all possible sub-arrays of an array
- Find the first, second and third minimum elements in an array
- Minimum product in a grid of adjacent elements
- Minimum value to be assigned to the elements so that sum becomes greater than initial sum
- Minimum operations required to set all elements of binary matrix
- Program to print N minimum elements from list of integers
- XOR of XORs of all sub-matrices
- Different Operations on Matrices
- Minimum sub-array such that number of 1's in concatenation of binary representation of its elements is at least K
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.