快速幂,a的b次方;
LL sm(LL a, LL b) { LL ans = 1; a = a%mod; while (b > 0) { if (b % 2 == 1) ans = (ans*a) % mod; b = b / 2; a = (a*a) % mod; } return ans%mod; }
posted on 2016-07-29 11:17 远搏 阅读(116) 评论(0) 编辑 收藏 举报
Powered by: 博客园 Copyright © 2024 远搏 Powered by .NET 8.0 on Kubernetes