Xn is an (even) integer, and what we really want to find is the last three digits of (Xn - 1) >From Xn = 2*a_n, so what we really seek is (2*a_n - 1) mod 1000. (more formally, an element of Z/1000Z)
If I know correctly, Python will give correct output if one writes like this (i.e. 2*a_n - 1 mod 1000), but in other languages like C, C++ and Java, they "might" give negative values - so they're writing (2*a_n + 999) mod 1000. Doesn't make much of a difference as its really the same, as -1 is congruent to 999 mod 1000. Yes, about the second question, you're right, there is a typo. 2013/7/13 chase <[email protected]> > I am practicing previous year question. > I was having problem in understanding the contest analysis of ROUND 1A( C > ) quesn. 2008 > > There are different solutions available . I was working on 'solution A' of > this ques. > > It is written Xn=(2*A_n)%1000 , but why did final result is Xn=( 2*A_n > +999 )%1000 > why 999 is added again? > > and second there is some typing mistake in the python code provided in > solutionA > It is written :: return (2 * M_n[0][0] + 999) % 1000 > It should be :: return (2 * A_n[0][0] + 999) % 1000 > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/1ce42301-edf4-453c-8a0d-a4220f080a31%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAA0%2BsYsGrQtZUPjiEb72JN%3D%3DndUCg8vi8g2O4UZD2oYTVp9TxA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
