Problem 3

0

0 votes
Problem

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as shown in the matrix in the Sample Input( Open the PlainText Link for better visualization).

It can be verified that the sum of the numbers on the diagonals is 101. (1+3+5+7+9+13+17+21+25=101)

Print the sum of the numbers on the diagonals in a 101 by 101 spiral formed in the same way?

Time Limit: 10
Memory Limit: 256
Source Limit:
Explanation

Hint: Don't try solving by Brute Force, instead try a smarter algorithm.

Sample Input and Sample Output are just for explanation, the program does not take any Inputs.

Editor Image

?