This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub Luzhiled/syakyo-library
#include "src/math/modular-arithmetic/mod-pow.hpp"
#pragma once #include "src/cpp-template/header/int-alias.hpp" namespace luz { i64 mod_pow(i64 b, i64 e, i64 mod) { if (mod == 1) return 0; i64 ans{1}; while (e) { if (e & 1) { ans = ans * b % mod; } b = b * b % mod; e /= 2; } return ans; } }
#line 2 "src/math/modular-arithmetic/mod-pow.hpp" #line 2 "src/cpp-template/header/int-alias.hpp" #include <cstdint> namespace luz { using i32 = std::int32_t; using i64 = std::int64_t; using u32 = std::uint32_t; using u64 = std::uint64_t; } #line 4 "src/math/modular-arithmetic/mod-pow.hpp" namespace luz { i64 mod_pow(i64 b, i64 e, i64 mod) { if (mod == 1) return 0; i64 ans{1}; while (e) { if (e & 1) { ans = ans * b % mod; } b = b * b % mod; e /= 2; } return ans; } }