I wrote a solution to 525E that works... just not on Codeforces. It produces correct output both on my machine and on Ideone, but prints something different on Codeforces.
Here is the submission: http://codeforces.net/contest/525/submission/11007405
And the Ideone test: http://ideone.com/IMONbz
My guess would be out-of-bounds memory access, but I can't find that anywhere... could somebody please help me?
Edit:
Thank you for the replies! It was indeed caused by pow
. Didn't expect to it to produce floating point numbers even when fed integers. A lesson learned, I guess. Sometimes I wish for Haskell's ^
(yes, I know it's XOR in c++).
The new submission: http://codeforces.net/contest/525/submission/11008141
Yellows use
pow
, really?I think the problem is on pow(3, n / 2). pow() is a floating point function and it may give different outputs on different platforms or compilers.
So i think using an array to stores the value of 3^x is a better way in this case and hope you can AC it.
I guess it is the pow precision thing. See this one