eat_code's blog

By eat_code, history, 7 years ago, In English

Can someone please identify the problem with the submission 24848243 . It got hacked during the contest by Endagorion and I resubmitted it by removing the floor which I had used unnecessarily while computing total range for a given n. I don't think it should make a difference though. Resubmission ID : 24860951

Thanks in advance.

  • Vote: I like it
  • +2
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by eat_code (previous revision, new revision, compare).

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Your Hacktest is
1125899906842623 1125899906742623 1125899906842623
I tested this on my Accepted Code. It prints 100001 on Codeforces but on Ideone and my PC it prints 50000.
Can someone please explain this ?

  • »
    »
    7 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    Even my code had the output 5000 for the hacktest. Also hacktest is one of the maintests(test 29)

    • »
      »
      »
      7 years ago, # ^ |
      Rev. 2   Vote: I like it +2 Vote: I do not like it

      I just changed log2() to my own LOG2() function and now its working fine.
      Now I can see the reason why all top coders use their own log function. Never use C++ log() and pow() function or any similar function as it may give unexpected results on some machine.

      I just added my own log function to your rejected code and now it gives correct output 100001 for the hacktest.

      your_code
      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +4 Vote: I do not like it

        Oh..thanks. I'll take care about this in future

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        Yeah, even i noticed that.:( Lesson learnt though

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

1125899906842623=2^50-1. Perhaps it's because of the loss of significance when you use the floor.