题目大意
有三个颜色,每个颜色的点数为$a,b,c$,现在在点之间连边,使得任意两个相同颜色的点间要么不存在路径要么路径长度$\ge 3$。
题目分析
显然我们可以将AB集合的合法方案、AC集合的合法方案、BC集合的合法方案合并起来就是ABC集合的合法方案。
故设状态:$f[i,j]$表示两个集合,一个个数为$i$,一个为$j$的合法方案。
得出状态转移方程:
代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include<algorithm> #include<iostream> #include<iomanip> #include<cstring> #include<cstdlib> #include<vector> #include<cstdio> #include<cmath> #include<queue> using namespace std; typedef long long LL; inline const LL Get_Int() { LL num=0,bj=1; char x=getchar(); while(x<'0'||x>'9') { if(x=='-')bj=-1; x=getchar(); } while(x>='0'&&x<='9') { num=num*10+x-'0'; x=getchar(); } return num*bj; } const LL mod=998244353; LL n,a,b,c,f[5005][5005]; int main() { a=Get_Int(); b=Get_Int(); c=Get_Int(); n=max(a,max(b,c)); for(int i=0; i<=n; i++)f[i][0]=f[0][i]=1; for(int i=1; i<=n; i++) for(int j=1; j<=n; j++) f[i][j]=(f[i-1][j]+f[i-1][j-1]*j%mod)%mod; printf("%I64d\n",f[a][b]*f[a][c]%mod*f[b][c]%mod); return 0; } `
|