欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

2017CCPC杭州部分题解

程序员文章站 2024-02-10 16:09:04
...

Problem B. Master of Phi

2017CCPC杭州部分题解

题意:给m对数p, q,令2017CCPC杭州部分题解,求2017CCPC杭州部分题解,其中2017CCPC杭州部分题解.

思路:公式化简。

          

2017CCPC杭州部分题解

 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;
}