All problems

Forcing Square Cells

easyPythonSeabornsquare

Brindle & Co builds a square grid where the rows and the columns are the same list of depots: the cell where a depot meets itself holds what it shipped to its own stores, and the rest hold transfers out to other depots. Because both axes mean the same thing, the chart is drawn with cells that are exactly square. The self-supply figure is what the internal report needs.

Task: Print the total of the cells where a depot meets itself.

Input

The first line holds one integer n, the number of depots, where 1 <= n <= 100. Then come n lines, each holding n numbers separated by single spaces: one row of the square grid.

Output

One line holding the total of the cells running from the top-left corner down to the bottom-right, rounded to 2 decimal places. That is the top-left-to-bottom-right diagonal, not the other one.

Example:

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

Output:
15.00

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…