QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#600271 | #8833. Equalizer Ehrmantraut | ukuk# | WA | 0ms | 3544kb | C++14 | 824b | 2024-09-29 15:36:33 | 2024-09-29 15:36:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
const int N=1e6+5;
int qmi(int a,int b){
a%=mod;
int ret=1;
for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;
return ret;
}
int n,m;
int fac[N];
void solve(){
cin>>n>>m;
fac[0]=1;
for(int i=1;i<=m;i++){
fac[i]=fac[i-1]*i%mod;
}
int ans = qmi(m,n);
int coe=qmi(m,n-1);
int invm=qmi(m,mod-2);
for (int a = 1; a < m; ++a) {
int t=a*invm%mod;
int up=mod+1-qmi(t,n);
int dn=mod+1-t;
int d=coe*(m-a)%mod*2%mod;
d*=up%mod;
d%=mod;
d*=qmi(dn,mod-2);
d%=mod;
ans+=d;
ans%=mod;
}
cout<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int _;
// cin>>_;
while(_--)solve();
return 0;
}
/*
5
a
sos
abba
icpc
tenet
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
1 3
output:
result:
wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements