code_astra's blog

By code_astra, history, 8 years ago, In English

Hi , for div 2 500 i just used GP formula approach with error range of +-100 . http://ideone.com/NjEMww It failed on test case (837592744927492746) but on ideone it is giving correct answer ! Can any one please explain why ? Is it bug of topcoder ?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it +1 Vote: I do not like it

On ideone it prints -1 while the answer should be 930658605474991929.

By the way what magic is this: if(f(i) - S == (long long )0)?

  • »
    »
    8 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    4) 837592744927492746 Returns: -1 This is what the top coder test case is. Well it is supposed to be same as comparing if f(i)(Limaks operation) is equal to the required sum for the ith number . Could you find the bug ?

    • »
      »
      »
      8 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The test case is "837592744927492746" and yes, your code returns -1. I doesn't mean that the correct answer is -1.

      I guess the mistake is that you don't use integers. You assume that pow() has precision 10 - 16, what isn't true.