zoukankan      html  css  js  c++  java
  • 2018牛客网暑期ACM多校训练营(第一场)A Monotonic Matrix(LGV)

    题意

    分析

    考虑01和12的分界线
    是(n, 0)到(0,m)的两条不相交(可重合)路径
    分界线以及分界线以上的点是一种,分界线下是一种
    平移其中一条变成(n-1, -1)到(-1,m-1);

    此时起点为{(n,0),(n-1,-1)}。终点为{(0,m),(-1,m-1)}。套LGV即可,答案为C(n+m,n)*C(n+m,n)-C(n+m,m-1)*C(n+m,m-1)。

    #include<iostream>
    #include<string.h>
    #include<stdio.h>
    #include<algorithm>
    #include<math.h>
    #include<vector>
    #include<map>
    using namespace std;
    typedef long long ll;
    const ll mod = 1e9+7;
    const int maxn =1005;
    ll dp[maxn][maxn];
    void init()
    {
        for(int i=1;i<maxn;i++)
        {
            dp[i][0]=dp[0][i]=1;
        }
        for(int i=1;i<maxn;i++)
        {
            for(int j=1;j<maxn;j++)
            {
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
        }
    }
    int main()
    {
        init();
        int n,m;
        while(~scanf("%d%d",&n,&m))
        {
            printf("%lld
    ",((dp[n][m]*dp[n][m])%mod-(dp[n-1][m+1]*dp[n+1][m-1])%mod+mod)%mod);
        }
    }
  • 相关阅读:
    浏览器版本过低
    虚拟PWN初探
    elasticsearch常用查询
    python安装pip模块
    spark-kafka-es交互 优化
    scala写文件
    python unittest
    scala collection(集合)
    spark-kafka-es交互
    scala语法
  • 原文地址:https://www.cnblogs.com/fht-litost/p/9350421.html
Copyright © 2011-2022 走看看