1
0
Fork 0

add: lpow

This commit is contained in:
arielherself 2025-01-04 17:56:19 +08:00
parent d4d2d86f43
commit 6ce8d08534
Signed by: arielherself
SSH Key Fingerprint: SHA256:AK3cyo9tFsp7Mox7K0sYphleC8hReXhnRKxwuDT5LBc
1 changed files with 13 additions and 0 deletions

13
number/examples/lpow.cc Normal file
View File

@ -0,0 +1,13 @@
constexpr int B = 2;
constexpr int N = 1e5;
constexpr int s = 31623; // sqrt(MDL)
int a[N], b[N];
void prep() {
a[0] = b[0] = 1;
for(int i = 1; i <= s; i++) a[i] = (ll)a[i - 1] * B % MDL ;
for(int i = 1; i <= s; i++) b[i] = (ll)b[i - 1] * a[s] % MDL ;
}
ll lpow(ll power) { return ll(b[power / s]) * a[power % s] % MDL; }