diff --git a/number/examples/lpow.cc b/number/examples/lpow.cc new file mode 100644 index 0000000..42c058f --- /dev/null +++ b/number/examples/lpow.cc @@ -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; } +