当前位置:网站首页>E - Integer Sequence Fair
E - Integer Sequence Fair
2022-08-01 22:42:00 【秦小咩】
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 500500 points
Problem Statement
Integer Sequence Exhibition is taking place, where integer sequences are gathered in one place and evaluated. Here, every integer sequence of length NN consisting of integers between 11 and KK (inclusive) is evaluated and given an integer score between 11 and MM (inclusive).
Print the number, modulo 998244353998244353, of ways to give each of the evaluated sequences a score between 11 and MM.
Here, two ways are said to be different when there is an evaluated sequence A = (A_1, A_2, \ldots, A_N)A=(A1,A2,…,AN) that is given different scores by the two ways.
Constraints
- 1 \leq N, K, M \leq 10^{18}1≤N,K,M≤1018
- NN, KK, and MM are integers.
Input
Input is given from Standard Input in the following format:
NN KK MM
Output
Print the number, modulo 998244353998244353, of ways to give each of the evaluated sequences a score between 11 and MM.
Sample Input 1 Copy
Copy
2 2 2
Sample Output 1 Copy
Copy
16
Four sequences are evaluated: (1, 1)(1,1), (1, 2)(1,2), (2, 1)(2,1), and (2, 2)(2,2). There are 1616 ways to give each of these sequences a score between 11 and 22, as follows.
- Give 11 to (1, 1)(1,1), 11 to (1, 2)(1,2), 11 to (2, 1)(2,1), and 11 to (2, 2)(2,2)
- Give 11 to (1, 1)(1,1), 11 to (1, 2)(1,2), 11 to (2, 1)(2,1), and 22 to (2, 2)(2,2)
- Give 11 to (1, 1)(1,1), 11 to (1, 2)(1,2), 22 to (2, 1)(2,1), and 11 to (2, 2)(2,2)
- Give 11 to (1, 1)(1,1), 11 to (1, 2)(1,2), 22 to (2, 1)(2,1), and 22 to (2, 2)(2,2)
- \cdots⋯
- Give 22 to (1, 1)(1,1), 22 to (1, 2)(1,2), 22 to (2, 1)(2,1), and 22 to (2, 2)(2,2)
Thus, we print 1616.
Sample Input 2 Copy
Copy
3 14 15926535
# include<iostream>
# include<iomanip>
# include<algorithm>
# include<map>
# include<vector>
# include<set>
# include<cstring>
# pragma optimize(2)
# define mod1 998244353
# define mod2 998244352
using namespace std;
typedef long long int ll;
ll qp2(ll base, ll pow)
{
ll ans=1;
while(pow)
{
if(pow&1)
ans=ans*base%mod2;
pow>>=1;
base=base*base%mod2;
}
return ans;
}
ll qp1(ll base, ll pow)
{
ll ans=1;
while(pow)
{
if(pow&1)
ans=ans*base%mod1;
pow>>=1;
base=base*base%mod1;
}
return ans;
}
int main ()
{
ll n,k,m;
cin>>n>>k>>m;
if(m%998244353==0)
{
cout<<0;
return 0;
}
else
{
ll now=qp2(k%(mod2),n);
ll ans=qp1(m%(mod1),now);
cout<<ans<<'\n';
}
return 0;
}
Sample Output 2 Copy
Copy
109718301
Be sure to print the count modulo 998244353998244353.
=========================================================================
费马小定理的应用
正整数 n , 当模数p是质数,且 gcd(n,p)==1时,n^(p-1)=1 (mod p)
本题答案显然是
,显然会想到快速幂,但我们长做的快速幂,指数部分是无法进行取模操作的,而本题的指数一旦不取模,会立刻炸掉,所以考虑对指数进行一些操作
如果m与p不互质,又因为p是质数,故m一定是p的倍数,此时已知答案为0
如果m与p互质,那么,将k^n拆分成 x*(p-1) + mod ,左半部分答案是1,右半部分答案直接用快速幂就可以直接解决。
边栏推荐
- 联邦学习入门
- SOM Network 2: Implementation of the Code
- vscode hide menu bar
- vscode hide menu bar
- PHP算法之最接近的三数之和
- Go 微服务开发框架DMicro的设计思路
- seaborn笔记:可视化统计关系(散点图、折线图)
- excel vertical to horizontal
- dvwa 通关记录1 - 暴力破解 Brute Force
- Advanced Algebra_Proof_The algebraic multiplicity of any eigenvalue of a matrix is greater than or equal to its geometric multiplicity
猜你喜欢

数据增强--学习笔记(图像类,cnn)

【SeaTunnel】从一个数据集成组件演化成企业级的服务

blender3.2.1 unit setting

10年稳定性保障经验总结,故障复盘要回答哪三大关键问题?|TakinTalks大咖分享

SRv6 L3VPN的工作原理

leetcode刷题

编曲软件FL studio20.8中文版功能和作用

复现gallerycms字符长度限制短域名绕过

_ _ determinant of a matrix is higher algebra eigenvalue of the product, the characteristic value of matrix trace is combined

2022年最新河北建筑八大员(机械员)模拟考试题库及答案
随机推荐
(Translation) How the contrasting color of the button guides the user's actions
NgRx Store createSelector 的单步调试和源代码分析
罗克韦尔AB PLC RSLogix5000中的比较指令使用方法介绍
APP special test: traffic test
华为无线设备配置双链路冷备份(AP指定配置方式)
y84.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十五)
AQS
联邦学习在金融领域的发展和应用
【开源】Sentinel高性能高可用集群限流解决方案
JS prototype hasOwnProperty in 加方法 原型终点 继承 重写父类方法
Wechat Gymnasium Appointment Mini Program Graduation Design Finished Work (4) Opening Report
数据分析04
SQL Server (design database--stored procedure--trigger)
xctf攻防世界 Web高手进阶区 webshell
When solving yolov5 training: "AssertionError: train: No labels in VOCData/dataSet_path/train.cache. Can not train"
PHP算法之有效的括号
[Mobile Web] Mobile terminal adaptation
深度学习Course2第一周Practical aspects of Deep Learning习题整理
基于 OData 模型和 JSON 模型的 SAP UI5 表格控件行项目的添加和删除实现
小程序毕设作品之微信美食菜谱小程序毕业设计成品(7)中期检查报告