you_know_wh0's blog

By you_know_wh0, history, 5 years ago, In English

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

  • Vote: I like it
  • +3
  • Vote: I do not like it

| Write comment?
»
5 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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;