Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

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

i am getting negative value even after applying %M operation at all steps. i dont understand where i'm doing wrong//i wrote this code for C problem of today's contest-codeforces round #711

my code: my code

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

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

x=(x+M)%M; this will convert the negative value in to positive. Prove- x= x%M + M%M then M%M=0 so x=x%M;

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

    yeah, but why i am even getting negative values in the first place. i am computing values in such a way that their range is [0, M].