题目链接
https://www.lydsy.com/JudgeOnline/problem.php?id=4487
题解
枚举至多有行列种颜色的情况,容斥一下
代码
#include <cstdio>
int read()
{
int x=0,f=1;
char ch=getchar();
while((ch<'0')||(ch>'9'))
{
if(ch=='-')
{
f=-f;
}
ch=getchar();
}
while((ch>='0')&&(ch<='9'))
{
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
const int maxn=400;
const int mod=1000000007;
int quickpow(int a,int b,int m)
{
int res=1;
while(b)
{
if(b&1)
{
res=1ll*res*a%m;
}
a=1ll*a*a%m;
b>>=1;
}
return res;
}
int n,m,c,ans,C[maxn+10][maxn+10],pow[maxn+10][maxn*maxn+10];
int main()
{
n=read();
m=read();
c=read();
C[0][0]=1;
for(int i=1; i<=maxn; ++i)
{
for(int j=0; j<=i; ++j)
{
C[i][j]=C[i-1][j];
if(j>0)
{
C[i][j]+=C[i-1][j-1];
if(C[i][j]>=mod)
{
C[i][j]-=mod;
}
}
}
}
for(int i=1; i<=c+1; ++i)
{
pow[i][0]=1;
for(int j=1; j<=n*m; ++j)
{
pow[i][j]=1ll*pow[i][j-1]*i%mod;
}
}
for(int i=1; i<=n; ++i)
{
for(int j=1; j<=m; ++j)
{
for(int k=0; k<=c; ++k)
{
ans=(ans+1ll*(((n+m+c-i-j-k)&1)?(mod-1):1)*pow[k+1][i*j]%mod*C[n][i]%mod*C[m][j]%mod*C[c][k])%mod;
}
}
}
printf("%d\n",ans);
return 0;
}