用途
をで求める.
計算量
使い方
mop(a,b,mod)でが返る.
実装
int mop(int a, int n, int mod = LLONG_MAX) { int res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res;}Verify
//TODO
an (mod mod)をO(log(n))で求める.
O(logn)
mop(a,b,mod)でan (mod mod)が返る.
1int mop(int a, int n, int mod = LLONG_MAX) {2 int res = 1;3 while (n > 0) {4 if (n & 1)5 res = res * a % mod;6 a = a * a % mod;7 n >>= 1;8 }9 return res;10}//TODO
New content is available, click on reload button to update.
Downloading for offline use...