From 6ce8d08534507e063e06d58570725ec272166fd4 Mon Sep 17 00:00:00 2001 From: arielherself Date: Sat, 4 Jan 2025 17:56:19 +0800 Subject: [PATCH] add: lpow --- number/examples/lpow.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 number/examples/lpow.cc 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; } +