链接: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)

题解:

链接:https://blog.csdn.net/black_miracle/article/details/81128169

代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 2005
const ll mod=1e9+;
ll C[MAX][MAX];
void c()
{
for(int i=;i<MAX;i++)
{
C[i][]=;
for(int j=;j<=i;j++)
C[i][j]=(C[i-][j-]+C[i-][j])%mod;
}
}
int main()
{
c();
int n,m;
while(cin>>n>>m)
{
cout<<((C[n+m][n]*C[n+m][n])%mod-(C[n+m][n-]*C[n+m][n+])%mod+mod)%mod<<endl; //加+mod是为了防止出现负数
}
}

该题是一个定理来着,具体看这个链接:https://blog.csdn.net/qq_25576697/article/details/81138213

最新文章

  1. ActiveMQ的集群方案对比及部署
  2. C#开发微信门户及应用(5)--用户分组信息管理
  3. [CareerCup] 17.13 BiNode 双向节点
  4. Starting MySQL...The server quit without updating PID file
  5. com学习 2015-10-16
  6. 使用HTML5实现刮刮卡效果
  7. Oracle的学习三:java连接Oracle、事务、内置函数、日期函数、转换函数、系统函数
  8. ubuntu下nvm,node以及npm的安装与使用
  9. Git的使用-如何将本地项目上传到Github
  10. POJ1269 Intersecting Lines[线段相交 交点]
  11. search for a range(找出一个数在数组中开始和结束位置)
  12. 2D空间的OBB碰撞实现
  13. jQuery-全屏滚动插件【fullPage.js】API 使用方法总结
  14. Jenkins+Jmeter+Ant自动化集成环境搭建
  15. emoji表情存储到数据库的方法
  16. python之旅:面向对象进阶
  17. CSUOJ 1007 矩形着色
  18. 前端(十二):react-redux实现逻辑
  19. 垂直水平居中--css3
  20. 这些混账的开源库在煞笔Windows系统上的编译方法

热门文章

  1. mpvue 无法获取$store的问题
  2. mod_jk是Apache服务器的一个可插入模块
  3. 屏幕坐标点转UGUI坐标【包含屏幕适配】
  4. ubuntu-12.04.5-desktop-amd64 安装vmwaretools
  5. 没有dockerfile的情况下如何查看docker的镜像信息
  6. 【串线篇】sql映射文件-分布查询(下)cellection的1-n
  7. Cesium标点
  8. pandas模块之读取文件
  9. 浅析 http 接口
  10. Python的pip源切换为国内阿里云镜像