QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559512#8833. Equalizer Ehrmantrautpuppet#AC ✓210ms19340kbC++141.1kb2024-09-11 22:41:552024-09-11 22:41:55

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 22:41:55]
  • 评测
  • 测评结果:AC
  • 用时:210ms
  • 内存:19340kb
  • [2024-09-11 22:41:55]
  • 提交

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,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 19200kb

input:

1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 12ms
memory: 19244kb

input:

2 2

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 12ms
memory: 19244kb

input:

69 42

output:

608932821

result:

ok 1 number(s): "608932821"

Test #4:

score: 0
Accepted
time: 11ms
memory: 19236kb

input:

102 156

output:

748401290

result:

ok 1 number(s): "748401290"

Test #5:

score: 0
Accepted
time: 21ms
memory: 19264kb

input:

4646 95641

output:

89806680

result:

ok 1 number(s): "89806680"

Test #6:

score: 0
Accepted
time: 38ms
memory: 19340kb

input:

42849 215151

output:

242217237

result:

ok 1 number(s): "242217237"

Test #7:

score: 0
Accepted
time: 164ms
memory: 19220kb

input:

786416 794116

output:

472898000

result:

ok 1 number(s): "472898000"

Test #8:

score: 0
Accepted
time: 162ms
memory: 19240kb

input:

963852 789456

output:

353211048

result:

ok 1 number(s): "353211048"

Test #9:

score: 0
Accepted
time: 89ms
memory: 19244kb

input:

696969 424242

output:

787990158

result:

ok 1 number(s): "787990158"

Test #10:

score: 0
Accepted
time: 36ms
memory: 19280kb

input:

1000000 123456

output:

533491028

result:

ok 1 number(s): "533491028"

Test #11:

score: 0
Accepted
time: 210ms
memory: 19236kb

input:

1000000 1000000

output:

572586375

result:

ok 1 number(s): "572586375"

Test #12:

score: 0
Accepted
time: 173ms
memory: 19260kb

input:

123456 1000000

output:

486967129

result:

ok 1 number(s): "486967129"

Test #13:

score: 0
Accepted
time: 7ms
memory: 19212kb

input:

789456 1

output:

1

result:

ok 1 number(s): "1"

Test #14:

score: 0
Accepted
time: 3ms
memory: 19272kb

input:

852516 2

output:

148946358

result:

ok 1 number(s): "148946358"

Test #15:

score: 0
Accepted
time: 18ms
memory: 19240kb

input:

1 953646

output:

40087733

result:

ok 1 number(s): "40087733"

Test #16:

score: 0
Accepted
time: 8ms
memory: 19108kb

input:

3 7686

output:

278212472

result:

ok 1 number(s): "278212472"

Extra Test:

score: 0
Extra Test Passed