QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559510 | #8833. Equalizer Ehrmantraut | lntano | AC ✓ | 202ms | 19296kb | C++14 | 1.0kb | 2024-09-11 22:41:26 | 2024-09-11 22:41:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr int mod=998244353;
constexpr int N=1e6+10;
ll f[N],inv[N];
ll power(ll a,ll k){
ll ans=1;
a%=mod;
while(k){
if(k&1) ans=(ans*a)%mod;
a=(a*a)%mod;
k>>=1;
}
return ans;
}
void init(){
f[0]=inv[0]=1;
for(int i=1;i<N;i++) f[i]=f[i-1]*i%mod;
inv[N-1]=power(f[N-1],mod-2);
for(int i=N-2;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(ll n,ll k){
if(n<k||n<0||k<0) return 0;
return f[n]*inv[k]%mod*inv[n-k]%mod;
}
void solve(){
int n,m;
cin>>n>>m;
ll ans=0;
for(int i=1;i<=m;i++){
// for(int k=1;k<=n;k++){
// ans=(ans+2*C(n,k)%mod*power(i-1,n-k)%mod*power(m-i+1,k)%mod-C(n,k)*power(i-1,n-k)+mod)%mod;
// }
ans=(ans+2*power(m,n)%mod)%mod;
ans=(ans-power(i,n)+mod)%mod;
ans=(ans-power(i-1,n)+mod)%mod;
}
cout<<ans<<'\n';
}
int main(){
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
init();
int t=1;
// cin>>t;
while(t--) solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 19296kb
input:
1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 11ms
memory: 19292kb
input:
2 2
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 7ms
memory: 19184kb
input:
69 42
output:
608932821
result:
ok 1 number(s): "608932821"
Test #4:
score: 0
Accepted
time: 7ms
memory: 19296kb
input:
102 156
output:
748401290
result:
ok 1 number(s): "748401290"
Test #5:
score: 0
Accepted
time: 16ms
memory: 19196kb
input:
4646 95641
output:
89806680
result:
ok 1 number(s): "89806680"
Test #6:
score: 0
Accepted
time: 42ms
memory: 19200kb
input:
42849 215151
output:
242217237
result:
ok 1 number(s): "242217237"
Test #7:
score: 0
Accepted
time: 164ms
memory: 19192kb
input:
786416 794116
output:
472898000
result:
ok 1 number(s): "472898000"
Test #8:
score: 0
Accepted
time: 169ms
memory: 19176kb
input:
963852 789456
output:
353211048
result:
ok 1 number(s): "353211048"
Test #9:
score: 0
Accepted
time: 85ms
memory: 19292kb
input:
696969 424242
output:
787990158
result:
ok 1 number(s): "787990158"
Test #10:
score: 0
Accepted
time: 29ms
memory: 19164kb
input:
1000000 123456
output:
533491028
result:
ok 1 number(s): "533491028"
Test #11:
score: 0
Accepted
time: 202ms
memory: 19176kb
input:
1000000 1000000
output:
572586375
result:
ok 1 number(s): "572586375"
Test #12:
score: 0
Accepted
time: 177ms
memory: 19228kb
input:
123456 1000000
output:
486967129
result:
ok 1 number(s): "486967129"
Test #13:
score: 0
Accepted
time: 3ms
memory: 19164kb
input:
789456 1
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 12ms
memory: 19232kb
input:
852516 2
output:
148946358
result:
ok 1 number(s): "148946358"
Test #15:
score: 0
Accepted
time: 15ms
memory: 19292kb
input:
1 953646
output:
40087733
result:
ok 1 number(s): "40087733"
Test #16:
score: 0
Accepted
time: 3ms
memory: 19116kb
input:
3 7686
output:
278212472
result:
ok 1 number(s): "278212472"
Extra Test:
score: 0
Extra Test Passed