HDU6256 Master of Phi (狄利克雷卷积、欧拉函数)

UPC5044
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
const int maxn = 1e6 + 100;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
typedef long long ll;

ll powmod(ll a, ll b) {
    ll ret = 1;
    while (b) {
        if (b & 1) ret = ret * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ret;
}


int main() {
    freopen("input.txt", "r", stdin);
    int _;
    scanf("%d", &_);
    while (_--) {
        int n;
        ll p, q;
        ll ans = 1;
        scanf("%d", &n);
        while (n--) {
            scanf("%lld %lld", &p, &q);
            ll temp = (p + (p - 1) * q) % mod;
            temp = temp * powmod(p, q - 1) % mod;
            ans = ans * temp % mod;
        }
        printf("%lld
", ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/albert-biu/p/10659894.html