题解:P16814 [蓝桥杯 2026 国 Python B] 蓝桥大富翁
neo20131118 · · 题解
数学题。以下记
我们设这
所以迭代
C++代码:
#include <bits/stdc++.h>
#define Rainbow return
#define after 0
#define rain
#define ll long long
using namespace std;
ll n=2026,p=998244353;
ll qp(ll x,ll y){
ll res=1,tmp=x;
while(y){
if(y%2) res=(res*tmp)%p;
tmp=(tmp*tmp)%p;
y>>=1;
}
return res;
}
ll QP(ll x,ll y){
ll res=1,tmp=x,P=p-1;
while(y){
if(y%2) res=(res*tmp)%P;
tmp=(tmp*tmp)%P;
y>>=1;
}
return res;
}
ll f(ll x){
ll res=1;
for(int i=1;i<=x;i++){
res=(res*i)%p;
}
return res;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
ll t=f(n);
cout<<qp(t,QP(n-1,n));
Rainbow after rain;
}
答案: