Grid Sums

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 16M

Problem type
Peg Test - March 9

Given a z by z grid of numbers and two numbers x and y. Output the sum of the numbers in row x and the sum of the numbers in column y.

Input Specification

z, followed by the rows of the grid on separate lines. z will be less than or equal to 10.
T, how many different sets of x and y to input.
x and y on the same line after the grid.

x, y, T \le 100

Output Specification

The sum of the numbers in row x and column y.

Sample Input

3
1 2 3
4 5 6
7 8 9
2
1 3
2 2

Sample Output

24
30

Comments

There are no comments at the moment.