peaceful_warrior's blog

By peaceful_warrior, 10 years ago, In English

I am getting wrong answer for Test Case 4(Problem C) : http://mirror.codeforces.com/contest/546/submission/11226594

But When I run the same Code in Ideone and My Linux Machine I am getting the correct output.

MY code (same as submission Link above): http://ideone.com/NmWgjc

Don't Know why Such Weird Problem is happening. Any Help Will be Appreciated.

  • Vote: I like it
  • -7
  • Vote: I do not like it

| Write comment?
»
10 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Try to submit your code again but without using pow function

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

    Got it Thanks.

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

      But can u still find the reason that pow function work well in Linux machine and Ideone and why not here in Codeforces Judge??

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

        Pow function returns double value hence when you cast to int something like pow(2, 3) (which is actually 8) you can easily get 7, because 7 = (int)7.9999999999.

        Btw, it was discussed like.. a lot.

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

11230498 got AC. If the result of pow should be an integer,you can add it by 0.5 before casting it,so things like 7.99999 will become 8.49999 and then become 8.