Algorithm of 913 - Joana and the Odd Numbers

Problem Description Link

To solve  this problem you need short-curt method other wise you get time limit exit
ie.
1
 3  5  7
 9 11 13 15 17
19 21 23 25 27 29 31
...
you need know line no.
line-1: 1
line-2:
 line-3 : 3  5  7
line-4:
line-5:  9 11 13 15 17
line-6:
line-7: 19 21 23 25 27 29 31
...
if you know last odd number from deasired line you can evaluate easilly sum of last 3 number
determine line no lineno=(n+1)/2
method of last odd number from deasired line =lineno*lineno*2-1
image

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience