Two ACs codes output different result

Revision en1, by txingml, 2018-09-08 19:11:26

I found a very strange problem in Educational Codeforces Round 50 F. Relatively Prime Powers.

First, here is a AC code written by me. https://mirror.codeforces.com/contest/1036/submission/42680029

And If you add a line "assert(val != 999999999999999956LL);", then this code will fail on test 3. It means test 3 has a case that num = 999999999999999956. https://mirror.codeforces.com/contest/1036/submission/42680073

But This is another AC code written by @alonefight, https://mirror.codeforces.com/contest/1036/submission/42657108. I ran it in my local environment and compared with my code. The result is surprised.

I used the test case as follow. 1 999999999999999956

My result is 999999998998996625 But @alonefight's result is 999999998998996624

I submitted his code and it still passed all test case. https://mirror.codeforces.com/contest/1036/submission/42680102

FYI, my environment is macbook, clion, c++14.

Can anyone tell me why this strange thing happened?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English txingml 2018-09-08 19:11:50 12 Tiny change: 'y strange problem in Educat' -> 'y strange thing in Educat'
en1 English txingml 2018-09-08 19:11:26 1012 Initial revision (published)