Fork me on GitHub

  2013年2月6日
摘要: 分类: 1.1 C/C++ 2009-07-29 16:24 902人阅读 评论(0) 收藏 举报 很多地方用到模运算,这里说明模运算的一些规律,并加以证明。 后续会对这些理论实际的应用加以记录和说明。1. 模运算是取余运算(记做 % 或者 mod),具有周期性的特点。 m%n的意思是n除m后的余数, 当m递增时m%n呈现周期性特点, 并且n越大,周期越长,周期等于n。 例如 0 % 20 = 0,1 % 20 = 1, 2 % 20 = 2, 3 % 20 = 3, ..., 19 % 20 = 19 20 % 20 = 0,21 % 20 = 1,22... 阅读全文
posted @ 2013-02-06 13:29 huashiyiqike 阅读(592) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<cstdio>#include<algorithm>#define max(a,b) ((a)>(b)?(a):(b))int qpow(int a,int b){ __int64 res=1; while(b) { if(b&1) { res*=a;res%=29;} a*=a;a%=29;b>>=1; } return (int)res;}int main(){// freopen("in.txt","r",stdin); int i, 阅读全文
posted @ 2013-02-06 13:20 huashiyiqike 阅读(205) 评论(0) 推荐(0) 编辑