Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
41200 氩_wjy 【BJ】T2 C++ 解答错误 0 0 MS 292 KB 1408 2026-04-11 15:46:29

Tests(0/4):


#include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; const int N=1e4+7,mod=998244353; int n,k; int f[N<<1]; int S[N]; int Ans[N]; inline void Add(int &a,int b){a+=b;a>=mod?a-=mod:a;} inline int qpow(int a,int b){ int Ans=1; while(b){ if(b&1)Ans=Ans*a%mod; a=a*a%mod;b>>=1; }return Ans; } int Inv[N]; inline void slv(int n,int k){ Ans[0]=S[0]=f[0]=1; int iFac=1; for(int t=1;t<=n;t++){ Inv[t]=(t==1?1:Inv[mod%t]*(mod-mod/t)%mod); (iFac*=Inv[t])%=mod; for(int j=t;j>=0;j--){ (S[j]*=j)%=mod; if(j)Add(S[j],S[j-1]); } // for(int j=0;j<=t;j++)cout<<S[j]<<" "; // cout<<endl; int G=0; for(int j=2*t;j>=0;j--){ int s=(f[j]+(j>=1?f[j-1]*2:0)+(j>=2?f[j-2]:0))%mod; f[j]=s*(j*(j-1)/2)%mod; } G%=mod; // for(int j=0;j<=2*t;j++)cout<<f[j]<<" "; // cout<<endl; Ans[t]=qpow(G,k); for(int p=0;p<t;p++)Ans[t]+=(mod-S[p]*Ans[p]%mod); Ans[t]%=mod; cout<<Ans[t]*iFac%mod<<endl; } } signed main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifndef ONLINE_JUDGE freopen("count.in","r",stdin); freopen("count.out","w",stdout); #endif int n,k;cin>>n>>k; slv(n,k); cout.flush(); return 0; }


测评信息: