牛客网暑期ACM多校训练营(第一场) A Monotonic Matrix【LGV】

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

将0 1 2填入矩阵,使得 a[i][j]>=a[i1][j] a [ i ] [ j ] >= a [ i − 1 ] [ j ] && a[i][j]>=a[i][j1] a [ i ] [ j ] >= a [ i ] [ j − 1 ]
抽象:将0 1的分割线视作一条路径,将1 2的分割线视作一条路径,问题可以转换成LGV问题。

这里写图片描述

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define clr(x,y) memset(x,y,sizeof x)
const int maxn=2e3+50;
const ll p=1e9+7;
ll c[maxn][maxn];
int main()
{
    int n,m;clr(c,0);
    for(int i=1;i<maxn;i++){
        c[i][0]=1;c[i][i]=1;
        for(int j=1;j<maxn;j++){
            if(!c[i][j])
            c[i][j]=(c[i-1][j]+c[i-1][j-1]+p)%p;

        }
    }
    //cout<<c[2][2]<<endl;
    while(scanf("%d %d",&n,&m)!=EOF){
        ll ans=0;
        ans+=c[n+m][n]*c[n+m][n]%p-c[n+m][m-1]*c[n+m][n-1]%p;
        ans+=p;
        ans%=p;
        printf("%lld\n",ans);
    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值