## 分析

$ans = \sum_{i=k}^{n}(-1)^{i-k}\binom{i}{k}A_n^iA_m^iA_l^i\prod_{j=1}^{i}P(j)$

## 代码

#include <bits/stdc++.h>

#define rin(i,a,b) for(int i=(a);i<=(b);++i)
#define irin(i,a,b) for(int i=(a);i>=(b);--i)
#define Size(a) (int) a.size()
#define pb push_back
#define mkpr std::make_pair
#define fi first
#define se second
#define lowbit(a) ((a)&(-(a)))
typedef long long LL;

using std::cerr;
using std::endl;

int x=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
return x*f;
}

const int MAXN=5000005;
const int MOD=998244353;

int n,m,l,k;
int fac[MAXN],invf[MAXN];
int cnt[MAXN],fix[MAXN];

inline int qpow(int x,int y){
int ret=1,tt=x%MOD;
while(y){
if(y&1)ret=1ll*ret*tt%MOD;
tt=1ll*tt*tt%MOD;
y>>=1;
}
return ret;
}

inline int C(int n,int m){
if(n<0||m<0||n<m)return 0;
return 1ll*fac[n]*invf[n-m]%MOD*invf[m]%MOD;
}

inline int A(int n,int m){
if(n<0||m<0||n<m)return 0;
return 1ll*fac[n]*invf[n-m]%MOD;
}

void init(int n){
fac[0]=1;
rin(i,1,n)fac[i]=1ll*fac[i-1]*i%MOD;
invf[n]=qpow(fac[n],MOD-2);
irin(i,n-1,0)invf[i]=1ll*invf[i+1]*(i+1)%MOD;
}

int main(){
init(5000000);
while(T--){
int inp[4];
std::sort(inp+1,inp+4);
n=inp[1],m=inp[2],l=inp[3];
int tot=1;
rin(i,1,n){
cnt[i]=(1ll*n*m%MOD*l%MOD-1ll*(n-i)*(m-i)%MOD*(l-i)%MOD+MOD)%MOD;
tot=1ll*tot*cnt[i]%MOD;
}
fix[n]=qpow(tot,MOD-2);
irin(i,n-1,1)fix[i]=1ll*fix[i+1]*cnt[i+1]%MOD;
int ans=0,sgn=MOD-1;
rin(i,k,n){
sgn=MOD-sgn;
ans=(ans+1ll*sgn*C(i,k)%MOD*A(n,i)%MOD*A(m,i)%MOD*A(l,i)%MOD*fix[i])%MOD;
}
printf("%d\n",ans);
}
return 0;
}


posted on 2019-05-21 22:30  ErkkiErkko  阅读(92)  评论(0编辑  收藏

• 随笔 - 91
• 文章 - 0
• 评论 - 20