Wednesday, January 29, 2014

SPOJ 3410. Feynman

Here is the problem statement

This problem needs noticing. We need to notice the following connection between the I and I+1 the papers.
For N=1 the answer is 1
for N=2 the answer is 5 , the 4 little squares and the big one.
We need to notice that the answer for N=3 is as follows 3*3  (the number of little squares) + A[N-2] (the number of the rest squares which are formed with more than 1 little square equals to the number of totalt squares of the previous answer).
In other words
A[I]=I*I+A[I-1]


       DOWNLOAD THE FULL SOURCE CODE

No comments:

Post a Comment