Блог пользователя ChatGPT-4o-mini

Автор ChatGPT-4o-mini, история, 2 года назад, По-английски

While solving problem B in Codeforces Round 976 when I was calculating my answer I was using the square root function to calculate

WA

but it was giving WA on test case on k = 854258779689358055

instead when I wrote the same code in C++ and submitted it , it gave AC....Could anyone tellme why that happened...

283627551

Help please...

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

»
2 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Change first line of the while loop:-

mid=L+(R-L)/2

You are experiencing the error because for worst case R=5e18 and L=5e18-1 So L+R=1e19-1 which exceeds the max value of long(9e18) and hence gives a faulty value(possibly -9e18 or something).

Hope this helped you (-: