HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Linear Data Structures: Arrays > problem:


51089 - Multiply a row and add it to another

Guest
• Review clarifications (2)

Section problems

• 51141 - Most valuable stock items
• 51014 - Nine Men's Morris game
• 51019 - Finding the hidden message
• 50497 - Falling Bricks - Revisited
• 50933 - Sum of the Biggest Neighbors
• 51100 - Minimum time to exit building
• 50444 - n digit kth number divisible...
• 50865 - Apartment Building Adminis...
• 51089 - Multiply a row and add i...
• 50874 - Apartment Building Adminis...
• 50531 - File Decryption
• 51012 - Palindrome-k
• 50469 - Letter Grades
• 50525 - Ordering Pizza
• 51099 - Mr. Monk
• 50468 - Draw Matrix - 2
• 51096 - Guess the number - 2

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.

Multiply a row and add it to another

In gaussian elimination, the rows are multiplied with a constant and added over another. The following adds s times Rowi to Rowj

sRi + Rj --> Rj

Question: Write a program reads a 2D array and three integers (i, j and s). And calculates and prints the new array.

Input specification: First, you will be two integers: the number of rows (n) and the number of columns (m). Each of the following n lines will contain m integer. Then, you will be given 3 integers:(i, j and s) where m, n, i and j are between 2 and 100, s is between 1 and 100 the numbers in 2D array are between -1000 and +1000.

Output specification: Show the new 2D array.

Sample Input I Sample Input II
4 3
4 7 1
2 3 10
1 10 5
1 5 6
3 2 -2
3 4
-5 10 10 9
-10 -1 -7 2
2 -6 -3 -2
3 1 2
Sample Output I Sample Output II
4 7 1
0 -17 0
1 10 5
1 5 6
-1 -2 4 5
-10 -1 -7 2
2 -6 -3 -2

Explanation: In sample input I, there is 1 in the first array, but it does not exist in the second array. All the numbers in two arrays appears at least one in two arrays in the second sample.



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

www.contester.ru