C++模运算

整理一下模运算的几个性质


\(a \bmod b \Leftrightarrow a \% b\)

\(a=mp+x,b=np+y,\)其中\(m,n\in Z,x,y\in N^{*},0\leq x,y <p\)
自己带进去运算,易证

  1. \((a+b)\%p=(a\%p+b\%p)\%p\)
  2. \((a+b)\%p=(a\%p+b\%p)\%p\)
  3. \(a\times b \% p=((a \% p)\times(b \% p))\%p\)

C++中我们可以这样缩写
\(a =a\% b \Leftrightarrow a \% =b\)

posted @ 2020-11-12 20:09  幽灵轩  阅读(434)  评论(0编辑  收藏  举报