library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub komori3/library

:heavy_check_mark: modpow
(lib/modpow.hpp)

概要

TBD

使い方

TBD

計算量

TBD

Verified with

Code

/**
 * @brief modpow 
 * @docs docs/modpow.md
 */
template<typename T = int64_t>
T modpow(T n, T power, T mod) {
    T res = 1;
    while (power > 0) {
        if (power & 1) res = res * n % mod;
        power >>= 1;
        n = n * n % mod;
    }
    return res;
}
#line 1 "lib/modpow.hpp"
/**
 * @brief modpow 
 * @docs docs/modpow.md
 */
template<typename T = int64_t>
T modpow(T n, T power, T mod) {
    T res = 1;
    while (power > 0) {
        if (power & 1) res = res * n % mod;
        power >>= 1;
        n = n * n % mod;
    }
    return res;
}
Back to top page