Solution
由题意得 ,若确定了 与 ,我们就可以通过递推计算任意的 :
设 ,则我们可以将上式改写为
接下来考虑限制 。由于我们容易刻画出 与 ,所以这只相当于两条限制:
考虑枚举 与 并选出 个 , 个 ,另外 个 ,插板法容易得到答案的表达式:
右边的和式是上指标范德蒙德卷积,给它赋一个组合意义:我们要从 个物品中选出 个,右边的和式就是在枚举第 个物品的位置。所以原式就是
枚举 ,原式即为:
容易 计算。
Solution
bool Mst;
#include<bits/stdc++.h>
using namespace std;
using ui=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
using u128=__uint128_t;
using pii=pair<int,int>;
#define fi first
#define se second
constexpr int N=3e5+5,mod=998244353;
inline ll add(ll x,ll y){return (x+=y)>=mod&&(x-=mod),x;}
inline ll Add(ll &x,ll y){return x=add(x,y);}
inline ll sub(ll x,ll y){return (x-=y)<0&&(x+=mod),x;}
inline ll Sub(ll &x,ll y){return x=sub(x,y);}
inline ll qpow(ll a,ll b){
ll res=1;
for(;b;b>>=1,a=a*a%mod)
if(b&1)res=res*a%mod;
return res;
}
int n;ll K,fac[N],ifac[N];
inline ll binom(int n,int m){
if(m<0||m>n)return 0;
return fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
bool Med;
int main(){
cerr<<abs(&Mst-&Med)/1048576.0<<endl;
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>K,K%=mod;
fac[0]=1;
for(int i=1;i<=n+1;i++)fac[i]=fac[i-1]*i%mod;
ifac[n+1]=qpow(fac[n+1],mod-2);
for(int i=n+1;i>=1;i--)ifac[i-1]=ifac[i]*i%mod;
ll dn=add(K,1),pw=1,ans=0;
for(int i=0;i<=n;dn=dn*(K-i++)%mod,Add(pw,pw))
Add(ans,binom(n,i)*dn%mod*ifac[i+1]%mod*pw%mod);
cout<<ans<<'\n';
return 0;
}