Problem B. Master of Phi:
题意:给m对数p, q,令,求
,其中
.
思路:公式化简。
AC代码:
/*---------------------------------
*File name: 2017杭州B.cpp
*Team: 这题太简单啦
*Author: Snpilola
*Creation date: 2019-10-08 15:37
*-------------------------------*/
#include<map>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define pb push_back
#define LL long long
#define mkp make_pair
#define PLL pair<LL, LL>
#define lowbit(x) x & (-x)
#define PII pair<int, int>
#define Pque priority_queue
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const int EPS = 1e-6;
LL fpow(LL x, LL y){
LL ans = 1;
while(y){
if(y & 1) ans = ans * x % mod;
x = x * x % mod;
y >>= 1;
}
return ans;
}
int main(){
int t; scanf("%d", &t);
while(t--){
int m;
LL p, q;
LL ans = 1;
scanf("%d", &m);
for(int i = 1; i <= m; i++){
scanf("%lld %lld", &p, &q);
ans = ans * fpow(p, q - 1) % mod * ((p + (p - 1) * q % mod) % mod) % mod;
}
printf("%lld\n", ans);
}
return 0;
}