QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197513#6417. Classical Summation Problemucup-team870#WA 11ms19212kbC++141.0kb2023-10-02 16:36:512023-10-02 16:36:52

Judging History

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

  • [2023-10-02 16:36:52]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:19212kb
  • [2023-10-02 16:36:51]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define per(i,r,l) for(int i=r; i>=l; i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
const int N=1e6+6,mod=998244353;
void add(ll &x,ll y){x=(x+y)%mod;}
ll qp(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)res=res*x%mod;
        x=x*x%mod; y>>=1;
    }
    return res;
}
ll fac[N],inv[N];
ll C(int i,int j){
    return fac[i]*inv[j]%mod*inv[i-j]%mod;
}
int main() {
    const int M=1e6;
    fac[0]=1; rep(i,1,M)fac[i]=fac[i-1]*i%mod;
    inv[M]=qp(fac[M],mod-2); per(i,M,1)inv[i-1]=inv[i]*i%mod;
    int n,k;cin>>n>>k;
    ll ans=0,nk=qp(n,k);
    rep(i,1,n/2){
        if(k&1){
            add(ans,nk);
        }
        else{
            add(ans,nk+C(k,k/2)*qp((1ll*i*(n-i)%mod),k/2) );
        }
    }
    if(n%2==0){
        int x=n/2; ll v=qp(x,k);
        rep(i,(k+1)/2,k)add(ans,C(k,i)*v%mod);
    }
    cout<<(n*nk-ans+mod)%mod;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 19004kb

input:

3 2

output:

14

result:

ok 1 number(s): "14"

Test #2:

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

input:

5 3

output:

375

result:

ok 1 number(s): "375"

Test #3:

score: -100
Wrong Answer
time: 7ms
memory: 19044kb

input:

2 2

output:

998244352

result:

wrong answer 1st numbers differ - expected: '5', found: '998244352'