算法取模运算规则

取模在很多算法题中较为常见,下面给出常用的算法取模运算规则:

(a + b) % m = (a % m + b % m) % m
(a - b) % m = (a % m - b % m) % m
(a * b) % m = (a % m * b % m) % m
a % c = (a % c) % c
algorithm
47 views
Comments
登录后评论
Sign In