Basic modulo operation, basic operation
2016.1.26
First popularized: a between B (mod m) means that the remainder of m of a and B is equal
The remainder of a modulo m is recorded as a mod m (naive I thought that the above three bars meant the remainder of the modulo)
Then there is the formula: assume a ≡ c (mod m) B ≡ d (mod m)
Then a + B then c + d (mod m)
A-B branch c-d (mod m)
A * B Branch c * d (mod m)
(Think about these formulas to find out why)
Note: # generally, the negative modulo result in c ++ is also a negative number. In this case, a % m + m can be changed to a positive value.
# In the case that the answer cannot blow up the int, the multiplication calculation in the process may also blow up the int, so long can be enabled in advance.
# Addition, subtraction, and multiplication all have easy-to-use formulas, but division is not the case. Let's talk about this next time.