1. 程式人生 > >HDU6256 Master of Phi (狄利克雷卷積、歐拉函數)

HDU6256 Master of Phi (狄利克雷卷積、歐拉函數)

urn can stdin () php lld 卷積 http bits

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\n", ans); } return 0; }

HDU6256 Master of Phi (狄利克雷卷積、歐拉函數)