HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Object Oriented Programming > problem:


50269 - Matrix Determinant

Volume problems

• 50530 - Sum of Ratios
• 50345 - Orders
• 50346 - The Biggest Date
• 50992 - Top K Obese Classes
• 50991 - Intersecting Circles
• 50989 - Rectangles and Points
• 50984 - Top m hardworking employees
• 50269 - Matrix Determinant
• 50986 - The Oldest Person
• 170. 50327 - Parallel Lines
• 50339 - The Largest Rectangle
• 130. 50326 - Matrix Operations
• 180. 50325 - How much time passed?
• 50318 - Product Info

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Question by Ibrahim Mesecan.

Matrix Determinant

Create a class called Matrix. The Matrix class will hold 2-by-2 integer matrix and have a function called determinant. The determinant of a 2-by-2 matrix is calculated as follows.


Make sure that the class also has
  • A default constructor and a copy constructor
  • Input and output stream operators. Every matrix is in a line (4 integers separated by spaces): A B C D
  • A Determinant function which returns the determinant of the matrix
  • Question: Then, write a program that reads n matrix information and then the program shows the matrices in descending order according to their determinants (the biggest determinant is at the top).

    Input specification
    You will be given two integers (n and m) the number of matrices, and the number of (m) top matrices to show. Then, in each of the following n lines you will be given 4 integers: A, B, C and D where 1 ≤ m ≤ n ≤ 10,000 and the numbers are between -20,000 and +20,000.

    Output specification
    Show the matrices in descending according to their determinants. If there are several matrices having the same determinant show the matrice which comes first in the input.

    Sample Input
    4 3
    0 1 7 2
    5 2 8 8
    5 8 5 1
    2 3 3 10
    Sample Output
    5 2 8 8
    2 3 3 10
    0 1 7 2

    Explanation: The determinant of 5 2 8 8 is 24 and the determinant of 5 8 5 1 is -35.


    Для отправки решений необходимо выполнить вход.

    www.contester.ru