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

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

https://codeforces.com/contest/1265/submission/68128052

Can anyone explain why this code is giving WA on test 6 and how do I correct it ? Thanks in advance.

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

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

Overflow is the cause. In the below line

i*(i-1)*1ll

As the expression is processed from left to right, i*(i-1) is stored in to 'int' first and only then it is multiplied by 1ll. So do 1ll*i*(i-1) to rectify it.