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\)
自己带进去运算,易证
- \((a+b)\%p=(a\%p+b\%p)\%p\)
- \((a+b)\%p=(a\%p+b\%p)\%p\)
- \(a\times b \% p=((a \% p)\times(b \% p))\%p\)
C++中我们可以这样缩写
\(a =a\% b \Leftrightarrow a \% =b\)
我是一颗水灵灵的大白菜,
农民伯伯辛勤的耕种着我,
把我带到了菜市场
拿着喷头对着我浇水,
还一边说“好菜啊好菜”