2017CCPC杭州部分题解
程序员文章站
2024-02-10 16:09:04
...
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;
}
上一篇: Vue项目打包后体积优化
下一篇: 使用和学习PHP有多难
推荐阅读
-
2017CCPC杭州部分题解
-
2017ccpc杭州 K. Master of Sequence(HDU - 6274 向下取整拆分 + 二分)
-
《算法:C语言实现》_第一部分_连通性问题解决算法
-
mysql用户自定义函数实例与部分问题解决方法
-
HTML5的Video标签有部分MP4无法播放的问题解析(多图)
-
洛谷CSP-J/S2020初赛模拟部分题解
-
win10部分软件显示模糊怎么办 win10系统软件显示不清楚问题解决方法
-
2019CCPC-江西省赛【部分题解】
-
Nordic Collegiate Programming Contest 2019 部分题解
-
2020 CCPC Wannafly Winter Camp Day1 (部分题解)