HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN110 Practice Exam 2 > problem:


3. 50269 - Matrix Determinant

CEN110 Practice Exam 2

Start: June.01.2017 at 09:08:00 AM
Finish: June.01.2017 at 10:05:00 AM
The contest is finished!
• Contest scoreboard

Contest problems

• 1. 50986 - The Oldest Person
• 2. 50526 - Gold Market
• 3. 50269 - Matrix Determinant
• 4. 50747 - Safe boxes against thieves

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