果的钩子公式
http://en.wikipedia.org/wiki/Young_tableau
黑书上也有的,最后在算的时候避免存不下,需要优化下。
#include <stdio.h>
#include <string.h>
int temp[20][50], up[50], down[50], num[20];
int n, m;
int gcd(int a, int b)
{
return (b == 0) ? a : gcd(b, a%b);
}
int main()
{
while ( scanf("%d", &m), m )
{
memset(temp, 0, sizeof(temp));
int i, j, k, n= 0, len= 0;
for ( i = 0 ; i < m ; i++ )
{
scanf("%d", num+i);
n+=num[i];
for ( j = 0 ; j < num[i] ; j++ )
temp[i][j]=1;
}
for ( i = 0 ; i < 20; i++ )
for ( j = 0 ; j < 50 && temp[i][j]; j++ )
{
int sum=-1;
for ( k = i ; k < 20 ; k++ )
sum+=temp[k][j];
for ( k = j ; k < 50 ; k++ )
sum+=temp[i][k];
if ( 0 < sum ) down[len++]= sum;
}
for ( i = 0 ; i < n ; i++ ) up[i]= i+1;
for ( i = 0 ; i < n ; i++ )
for ( j = 0 ; j < n ; j++ )
{
k = gcd(up[i], down[j]);
up[i]/=k;
down[j]/=k;
}
__int64 ans= 1;
for ( i = 0 ; i < n ; i++ )
ans*=up[i];
printf("%I64d\n", ans);
}
return 0;
}