mysql 排列组合_排列组合( Lindström–Gessel–Viennot lemma 定理)

链接:https://www.nowcoder.com/acm/contest/139/A

来源:牛客网

Monotonic Matrix

时间限制:C/C++ 1秒,其他语言2秒

空间限制:C/C++ 524288K,其他语言1048576K

64bit IO Format: %lld

题目描述

Count the number of n x m matrices A satisfying the following condition modulo (109+7). * Ai, j ∈ {0, 1, 2} for all 1 ≤ i ≤ n, 1 ≤ j ≤ m. * Ai, j ≤ Ai + 1, j for all 1 ≤ i < n, 1 ≤ j ≤ m. * Ai, j ≤ Ai, j + 1 for all 1 ≤ i ≤ n, 1 ≤ j < m.

输入描述:

The input consists of several test cases and is terminated by end-of-file.Each test case contains two integers n and m.

输出描述:

For each test case, print an integer which denotes the result.

示例1

输入

复制

1 2

2 2

1000 1000

输出

复制

6

20

540949876

备注:

* 1 ≤ n, m ≤ 103* The number of test cases does not exceed 105.

题意:

求有多少n*m的矩阵满足:

1.每个数都是0或1或2

2.a(i,j)<=a(i+1,j)

3.a(i,j)<=a(i,j+1)

题解:

1e1ee65a376909f10100e758123780fc.gif

代码:

#include

using namespacestd;

typedeflong longll;#define MAX 2005

const ll mod=1e9+7;

ll C[MAX][MAX];voidc()

{for(int i=0;i

{

C[i][0]=1;for(int j=1;j<=i;j++)

C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;

}

}intmain()

{

c();intn,m;while(cin>>n>>m)

{

cout<

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值