1 条题解

  • 1
    @ 2024-03-07 17:51:09

    快速幂板子。

    #include <cstdio>
    
    #define ll long long
    
    namespace Cirno {
        ll FastPower(ll base, ll power, ll mod) {
            ll result = 1;
            while (power) {
                if (power & 1) result = result * base % mod;
                power = power >> 1;
                base = base * base % mod;
            }
            return result;
        }
    }
    ll m;
    ll a, b, p;
    
    int main() {
        scanf("%lld", &m);
        while (m--) {
            scanf("%lld %lld %lld", &a, &b, &p);
            printf("%lld\n", Cirno::FastPower(a, b, p));
        }
        return 0;
    }
    
  • 1

灰灰的KPS / 【模板】快速幂

信息

ID
1005
难度
3
分类
快速幂 点击显示
标签
递交数
9
已通过
4
通过率
44%
上传者