Блог пользователя -Wave-

Автор -Wave-, 9 лет назад, По-английски

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.com/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.com/contest/525/submission/11008141

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +23 Проголосовать: не нравится

Yellows use pow, really?

»
9 лет назад, # |
  Проголосовать: нравится +21 Проголосовать: не нравится

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.

»
9 лет назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

I guess it is the pow precision thing. See this one