快速幂,但是 ext/numeric

· · 个人记录

学习自 https://www.luogu.me/article/2416ics3

#include <bits/stdc++.h>
#include <ext/numeric>
#define int long long
using namespace std;
int a, b, p;
struct Op
{
    inline const int operator()(int l, int r) { return l * r % p; }
    // 定义乘法运算
};
inline int identity_element(Op oo) { return 1 % p; } // 定义乘法运算的单位元(函数名不能修改)
signed main()
{
    cin.tie(0)->sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> a >> b >> p;
    cout << a << "^" << b << " mod " << p << "=" << __gnu_cxx::power(a, b, Op{}) << '\n';
    return 0;
}