#pragma once #include namespace algorithm { template T fast_power(T a, F n) { static_assert(std::is_arithmetic_v, "Radix must be arithmetic for fast power"); static_assert(std::is_integral_v, "Power must be integral for fast power"); T result{1}; while (n > 0) { if (n & 1) result *= a; a *= a; n >>= 1; } return result; } } // namespace algorithm