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

Автор thedsk, история, 7 лет назад, По-английски

I have been trying this question and i am getting wrong answer on testcase2.I m using codechef compiler right now and it is printing the expected output.But codeforces is giving me wrong answer and I dont know why.Link to my code is below and i have tried to submit this solution in two different languages GNUC++ and GNUC++11. If I increment x by 1 it fails test case 3.Can u plz help!!! http://codeforces.com/contest/808/submission/28206449

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

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

The function pow in C++ is only defined for floating point numbers. So pow(10, 2) might return 99.99999999999 instead of 100 (e.g. when performed on a different compiler / different architecture) and then get truncated to 99 when you convert it to an int. If you want to perform integer exponentiation, always write a pow function yourself.

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

I also had problem with pow in this problem at the contest, so I changed it to my own binary power function, it worked. Don't use pow, it is slow and it have problems with long long.

Here is your fixed submission: http://codeforces.com/contest/808/submission/28207320