链接:http://acm.hdu.edu.cn/showproblem.php?pid=6114

Problem Description
車是中国象棋中的一种棋子,它能攻击同一行或同一列中没有其他棋子阻隔的棋子。一天,小度在棋盘上摆起了许多車……他想知道,在一共N×M个点的矩形棋盘中摆最多个数的車使其互不攻击的方案数。他经过思考,得出了答案。但他仍不满足,想增加一个条件:对于任何一个車A,如果有其他一个車B在它的上方(車B行号小于車A),那么車A必须在車B的右边(車A列号大于車B)。 现在要问问你,满足要求的方案数是多少。 Input
第一行一个正整数T,表示数据组数。 对于每组数据:一行,两个正整数N和M(N<=,M<=)。 Output
对于每组数据输出一行,代表方案数模1000000007(1e9+)。 Sample Input Sample Output Source
"百度之星"程序设计大赛 - 初赛(B)

题干

就是简单的组合数。

#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define MOD 1000000007
#define LL long long
int n,m,t;
LL f[][];
int main()
{
scanf("%d",&t);
f[][]=;
for(int i=;i<=;i++)
{
f[i][]=;
for(int j=;j<i;j++)
f[i][j]=(f[i-][j-]+f[i-][j])%MOD;
f[i][i]=;
}
while(t--)
{
scanf("%d%d",&n,&m);
if(n>m) {int temp=m; m=n; n=temp;}
if(m==||n==)
{
cout<<<<endl;
continue;
}
cout<<f[m][n]<<endl;
}
return ;
}

代码

Chess 模拟的更多相关文章

  1. XTUOJ 1176 I Love Military Chess(模拟)

     I Love Military Chess Accepted : 45   Submit : 141 Time Limit : 1000 MS   Memory Limit : 65536 KB ...

  2. Codeforces Round #379 (Div. 2) D. Anton and Chess 模拟

    题目链接: http://codeforces.com/contest/734/problem/D D. Anton and Chess time limit per test4 secondsmem ...

  3. D. Anton and Chess 模拟题 + 读题

    http://codeforces.com/contest/734/problem/D 一开始的时候看不懂题目,以为象是中国象棋那样走,然后看不懂样例. 原来是走对角线的,长知识了. 所以我们就知道, ...

  4. Codeforces Round #157 (Div. 2)

    A. Little Elephant and Chess 模拟. B. Little Elephant and Magic Square 枚举左上角,计算其余两个位置的值,在\(3\times 3\) ...

  5. hihoCoder 1392 War Chess 【模拟】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1392 : War Chess 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Rainbow loves to play kinds of War Chess gam ...

  6. codeforces 893A Chess For Three 模拟

    893A Chess For Three 思路: 直接模拟即可,第一盘永远是A与B开始 代码: #include <bits/stdc++.h> using namespace std; ...

  7. Educational Codeforces Round 33 (Rated for Div. 2) A. Chess For Three【模拟/逻辑推理】

    A. Chess For Three time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  8. Codeforces 734D. Anton and Chess(模拟)

    Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the pro ...

  9. 20180520模拟赛T3——chess

    [问题描述] 小美很喜欢下象棋. 而且她特别喜欢象棋中的马. 她觉得马的跳跃方式很独特.(以日字格的方式跳跃) 小芳给了小美一张很大的棋盘,这个棋盘是一个无穷的笛卡尔坐标. 一开始\(time=0\) ...

随机推荐

  1. python cassandra 创建space table并写入和查询数据

    from cassandra.cluster import Cluster cluster = Cluster(["10.178.209.161"]) session = clus ...

  2. coeforces 665D D. Simple Subset(最大团orsb题)

    题目链接: D. Simple Subset time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. Anaconda tensorflow 安装笔记

    1.安装步骤: (1)Anaconda下载Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载.ps:也可 ...

  4. ubuntu16.04 + cuda9.0(deb版)+Cudnn7.1

    https://blog.csdn.net/Umi_you/article/details/80268983

  5. unittest执行测试用例的N种姿势总结

    1.我们写几个方法,用来做测试用例 2.我们在另一文件中引用这个模块下面的所有类方法,先看第一种方法: 运行结果: 缺点:每个用例都需要加载到测试套件中,如果有1000个用例,要写1000次重复的代码 ...

  6. Cube 数据 与 DW 数据对应不上

    场景: 时间维度表:字段(日期) 收费事实表:字段(金额,收费日期,就诊编号) 管理:使用维度表的 日期字段与事实表的 收费日期字段 进行关联,建立多维度数据集. 问题:     DW :   9月份 ...

  7. hdu-1597

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  8. E - Jolly Jumpers

    E - Jolly Jumpers Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit  ...

  9. mysql 三存储引擎

    一 什么是存储引擎 mysql中建立的库===>文件夹 库中建立的表===>文件 现实生活中我们用来存储数据的文件有不同的类型,每种文件类型对应各自不同的处理机制:比如处理文本用txt类型 ...

  10. sfc命令

    开始—>运行—>再输入“sfc /scannow”(不含引号),“sfc”是“系统文件检测”程序,它是一个在命令提示符下使用的实用程序,只有是管理员才能使用该程序,这个程序的作用就是检测系 ...