Hello, I'm Alan Estrada.
So this code succeeds for the small case but is off a little when it gets large. I am blaming this on arithmetical errors with doubles.
Source: http://stackoverflow.com/questions/2100490/floating-point-inaccuracy-examples
EDIT: I just changed everything to long longs and it works great. Submit the output at https://code.google.com/codejam/contest/189252/dashboard#s=p0 to test it out.