杨氏矩阵 and 钩子公式

44 篇文章 0 订阅
30 篇文章 1 订阅

杨氏矩阵 and 钩子公式

杨氏矩阵

  • 满足杨氏矩阵条件

    • 如果(i,j)没有元素,则它右边和上边的相邻格子也一定没有元素
    • 如果(i,j)有元素,则它右边和上边的相邻元素要么没有元素,要么有元素且比(i,j)大
  • 1~n所组成的杨氏矩阵的个数可以通过下面的递推式得到:

    F ( 1 ) = 1 , F ( 2 ) = 2 F(1)=1,F(2)=2 F(1)=1,F(2)=2

    F ( n ) = F ( n − 1 ) + ( n − 1 ) F ( n − 2 ) ,   ( n > 2 ) F(n)=F(n-1)+(n-1)F(n-2),\ (n>2) F(n)=F(n1)+(n1)F(n2), (n>2)

钩子公式:

  • 钩子长度:某一格子右边的格子数和它上边的格子数之和

  • 对于给定形状的杨氏矩阵,不同的杨氏矩阵个数 c n t cnt cnt 为:
    c n t = n ! g [ 1 ] g [ 2 ] . . . g [ n ] cnt=\frac{n!}{g[1]g[2]...g[n]} cnt=g[1]g[2]...g[n]n!
    g [ n ] g[n] g[n] 表示第n个格子的钩子长度+1

例题:2279 – Mr. Young’s Picture Permutations (poj.org)

  • 有一个小处理,这题是一个倒置的杨氏矩阵,所以处理的时候也要倒置处理
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;

typedef long long ll;
const int N=205;
int g[N], a[N];
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k;
	while(cin>>k && k)
	{
		for(int i=1;i<=k;i++) cin>>a[i];
		int tot=0;
		for(int i=k;i>=1;i--)
		{
			for(int j=1;j<=a[i];j++)
			{
				g[++tot]=a[i]-j+1;
				for(int q=i+1;q<=k;q++)
				{ 
					if(a[q]>=j) g[tot]++;
					else break;
				}
			}
		}
		ll x=1,y=1;
		for(int i=tot;i>=1;i--)
		{
			x*=i; y*=g[i];
			int d=gcd(x,y);
			x/=d; y/=d;
		}
		cout<<x<<endl;
	}
    return 0;
}
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

yezzz.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值