Wrong Answer in Arithmetic Puzzle(Matrix 2014)

Please tell me what is wrong with my code … It is the same question of “SPOJ” and their I got an AC but in “MATRIX 2014” getting WA… plzz help me
My code

This is what i did :


n = 2\*S/(third-last-term + third-term)  
d = (third-last-term - third-term)/(n - 5)  
a0 = third-term - 2*d

Brother you code is giving wrong series for the provided arithmetic series. For input
1
387 148608 28905030

your output is:
388(correct)
387 387 387 … (wrong series). :slight_smile:

you might have solved any other question.

@nfynt , If you think that I might have solved any other question here is the link…

And yeah first read the question carefully it is written that all the array elements will be positive and in this case the correct answer consists of negative numbers…