Given a number N denotes the total number of elements in a matrix, the task is to print all possible order of matrix. An order is a pair (m, n) of integers where m is number of rows and n is number of columns. For example, if the number of elements is 8 then all possible orders are:
(1, 8), (2, 4), (4, 2), (8, 1).
Input: N = 8
Output: (1, 2) (2, 4) (4, 2) (8, 1)
Input: N = 100
(1, 100) (2, 50) (4, 25) (5, 20) (10, 10) (20, 5) (25, 4) (50, 2) (100, 1)
A matrix is said to be of order m x n if it has m rows and n columns. The total number of elements in a matrix is equal to (m*n). So we start from 1 and check one by one if it divides N(the total number of elements). If it divides, it will be one possible order.
Below is the implementation of the above approach:
1 10 2 5 5 2 10 1
- Count sub-matrices having sum divisible 'k'
- Count pairs from two sorted matrices with given sum
- Minimum elements to be added so that two matrices can be multiplied
- Queries on number of Binary sub-matrices of Given size
- Count of subsequences having maximum distinct elements
- Count of elements of an array present in every row of NxM matrix
- Count of cells in a matrix which give a Fibonacci number when the count of adjacent cells is added
- XOR of XORs of all sub-matrices
- Different Operations on Matrices
- Count arrays of length K whose product of elements is same as that of given array
- Count elements smaller than or equal to x in a sorted matrix
- Count number of triplets with product equal to given number with duplicates allowed | Set-2
- Count number of triplets with product equal to given number with duplicates allowed
- Find the intersection of two Matrices
- Program for subtraction of 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.