### akzytr's blog

By akzytr, history, 7 weeks ago,

I could not solve 1909B - Make Almost Equal With Mod on my own and thus looked at the tutorial, which among other things writes the following:

if a % m = k:

a % 2m is either k, or k+m

Is there any proof/concept of modular arithmetic that explains why this is so?

• -1

 » 7 weeks ago, # | ← Rev. 2 →   0 given a % m == k , we can write a as k(= 0now we take a % 2*m , we get (k+n*m) % 2*m , we can take it as following cases : if n%2==0 then we have a % 2*m = (k+n*m) % 2*m = k if n%2==1 then we have a % 2*m = (k + m + (n-1)*m) % 2*m = k + m Thus we can have only two cases that can be shown as above
•  » » 7 weeks ago, # ^ |   0 If we have n%2 = 1How are we getting(k + m + (n-1)*m)Why are we getting the extra +m after k, and also why are we subtracting n by 1?
•  » » » 7 weeks ago, # ^ |   0 well n*m = (n-1)*m + m so there's that and subtracting n by 1 makes it even
•  » » 7 weeks ago, # ^ |   0 More readable nowgiven $a$%$m==k$ , we can write a as $k(= 0$now we take $a$%$2*m$ , we get $(k+n*m)$%$2*m$ , we can take it as following cases :if $n$%$2==0$ then we have $a$%$2*m = (k+n*m)$%$2*m = k$if $n$%$2==1$ then we have $a$%$2*m = (k + m + (n-1)*m)$%$2*m = k + m$Thus we can have only two cases that can be shown as above