QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#457212 | #8833. Equalizer Ehrmantraut | ucup-team3699# | AC ✓ | 135ms | 27088kb | C++23 | 1.0kb | 2024-06-29 09:11:56 | 2024-06-29 09:12:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define pb push_back
const int mol=998244353;
int p[1000005], fac[1000005], inv[1000005];
int ff(int g, int h){
int bas=g, ans=1;
while(h) {
if(h&1) ans*=bas, ans%=mol;
bas*=bas, bas%=mol;
h>>=1;
}
return ans;
}
int C(int g, int h){
return fac[g]*inv[h]%mol*inv[g-h]%mol;
}
void solve(){
int n, m;
cin>>n>>m;
int ans=1;
p[0]=1, fac[0]=1;
for(int i=1;i<=n;i++) ans*=m, ans%=mol;
int q=ans;
for(int i=1;i<=n;i++) p[i]=p[i-1]*(m-1)%mol, fac[i]=fac[i-1]*i%mol;
inv[n]=ff(fac[n], mol-2);
for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mol;
for(int i=1;i<m;i++){
ans+=(ff(m, n)-ff(i, n)+mol)*2, ans%=mol;
}
// ans-=q*2, ans%=mol, ans=(ans+mol)%mol;
cout<<ans<<"\n";
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
// int t;
// cin>>t;
// while(t--)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7748kb
input:
1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
2 2
output:
10
result:
ok 1 number(s): "10"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7744kb
input:
69 42
output:
608932821
result:
ok 1 number(s): "608932821"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7748kb
input:
102 156
output:
748401290
result:
ok 1 number(s): "748401290"
Test #5:
score: 0
Accepted
time: 6ms
memory: 7728kb
input:
4646 95641
output:
89806680
result:
ok 1 number(s): "89806680"
Test #6:
score: 0
Accepted
time: 14ms
memory: 10024kb
input:
42849 215151
output:
242217237
result:
ok 1 number(s): "242217237"
Test #7:
score: 0
Accepted
time: 117ms
memory: 25892kb
input:
786416 794116
output:
472898000
result:
ok 1 number(s): "472898000"
Test #8:
score: 0
Accepted
time: 110ms
memory: 26736kb
input:
963852 789456
output:
353211048
result:
ok 1 number(s): "353211048"
Test #9:
score: 0
Accepted
time: 59ms
memory: 23548kb
input:
696969 424242
output:
787990158
result:
ok 1 number(s): "787990158"
Test #10:
score: 0
Accepted
time: 28ms
memory: 27088kb
input:
1000000 123456
output:
533491028
result:
ok 1 number(s): "533491028"
Test #11:
score: 0
Accepted
time: 135ms
memory: 27088kb
input:
1000000 1000000
output:
572586375
result:
ok 1 number(s): "572586375"
Test #12:
score: 0
Accepted
time: 101ms
memory: 14152kb
input:
123456 1000000
output:
486967129
result:
ok 1 number(s): "486967129"
Test #13:
score: 0
Accepted
time: 13ms
memory: 26580kb
input:
789456 1
output:
1
result:
ok 1 number(s): "1"
Test #14:
score: 0
Accepted
time: 7ms
memory: 25872kb
input:
852516 2
output:
148946358
result:
ok 1 number(s): "148946358"
Test #15:
score: 0
Accepted
time: 3ms
memory: 7684kb
input:
1 953646
output:
40087733
result:
ok 1 number(s): "40087733"
Test #16:
score: 0
Accepted
time: 0ms
memory: 7744kb
input:
3 7686
output:
278212472
result:
ok 1 number(s): "278212472"
Extra Test:
score: 0
Extra Test Passed