链接: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. 记录用到的一些linux命令和疑难解决

    1. 用gedit打开.bashrc larry@larry-Rev:~$ sudo gedit ~/.bashrc 2. ubuntu里安装软件有点像iOS里的Cydia,要添加软件源来在Ubunt ...

  2. [练习]使用dx.bat、dexdump.exe、javap、Baksmali

    PART0 这几个工具的关系可以这样描述: 用例: public class Hello { public int foo(int a , int b ) { return (a+b) * (a-b) ...

  3. bzoj 3745 [Coci2015]Norma——序列分治

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3745 如果分治,就能在本层仅算过 mid 的区间了. 可以从中间到左边地遍历左边,给右边两个 ...

  4. vbs实现zip压缩

    VBS实现zip压缩 Zip "D:\test.xls", "D:\test.zip" Sub Zip(ByVal mySourceDir, ByVal myZ ...

  5. 前端之CSS2

    CSS盒子模型 CSS盒子模型介绍 盒子模型解释 元素在页面中显示成一个方块,类似一个盒子,CSS盒子模型就是使用现实中盒子来做比喻,帮助我们设置元素对应的样式. 盒子模型示意图如下: 把元素叫做盒子 ...

  6. CodeForces 586D【BFS】

    题意: s是这个人开始位置:连续相同大写字母是 Each of the k trains,相应的火车具有相应的字母: '.' 代表空: 有个人在最左列,上面有连续字母代表的火车,火车从左边出去的话,会 ...

  7. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  8. hdoj5493【树状数组+二分】

    题意: 给你n个人的高度, 再给出一个值代表该高度下有前面比他高的 或 后面比他高的人数, 求满足条件下的最小字典序, 不行的话输出"impossible" 思路: 对于最小字典序 ...

  9. 51nod1076(tarjan)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1076 题意:中文题诶- 思路:先用tarjan找出所有桥,再用 ...

  10. Optimized fragmentation improves the identification of peptides cross-linked by MS-cleavable reagents (文献分享一组-张宇星)

    题目:Optimized fragmentation improves the identification of peptides cross-linked by MS-cleavable reag ...