就是一个组合数水题

偷个图

去掉阴影部分  把整个图看成上下两个矩形

对于上面的矩形求出起点到每个绿点的方案

对于下面的矩形 求出每个绿点到终点的方案

上下两个绿点的方案相乘后相加 就是了 想想为什么

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <cctype>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#define rap(i, a, n) for(int i=a; i<=n; i++)
#define rep(i, a, n) for(int i=a; i<n; i++)
#define lap(i, a, n) for(int i=n; i>=a; i--)
#define lep(i, a, n) for(int i=n; i>a; i--)
#define rd(a) scanf("%d", &a)
#define rlld(a) scanf("%lld", &a)
#define rc(a) scanf("%c", &a)
#define rs(a) scanf("%s", a)
#define rb(a) scanf("%lf", &a)
#define rf(a) scanf("%f", &a)
#define pd(a) printf("%d\n", a)
#define plld(a) printf("%lld\n", a)
#define pc(a) printf("%c\n", a)
#define ps(a) printf("%s\n", a)
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff, MOD = 1e9 + ; LL D[maxn], U[maxn];
LL q_pow(LL a, LL b)
{
LL ret = ;
while(b)
{
if(b & ) ret = ret * a % MOD;
a = a * a % MOD;
b >>= ;
}
return ret;
} void init()
{
U[] = D[] = ;
for(int i = ; i < maxn; i++)
{
U[i] = U[i - ] * i % MOD;
D[i] = q_pow(U[i], MOD - );
}
} LL C(LL n, LL m)
{
return U[n] * D[m] % MOD * D[n - m] % MOD;
} int main()
{
init(); LL h, w, a, b, ret = ;
cin >> h >> w >> a >> b;
for(int i = b + ; i <= w; i++)
{
ret = (ret + C(h - a + i - , i - ) * C(a - + w - i, a - )) % MOD;
// cout << C(h - a + i - 2, i - 1) << " " << C(a - 1 + w - i, a - 1) << endl;
}
ret = (ret % MOD + MOD) % MOD;
cout << ret << endl; return ;
}

Iroha and a Grid AtCoder - 1974(思维水题)的更多相关文章

  1. HDU 2674 N!Again(数学思维水题)

    题目 //行开始看被吓一跳,那么大,没有头绪, //看了解题报告,发现这是一道大大大的水题,,,,,//2009 = 7 * 7 * 41//对2009分解,看它有哪些质因子,它最大的质因子是41,那 ...

  2. HDOJ/HDU 1256 画8(绞下思维~水题)

    Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...

  3. 2019年华南理工校赛(春季赛)--I--炒股(简单思维水题)

    水题,想想就过了 题目如下: 链接:https://ac.nowcoder.com/acm/contest/625/I来源:牛客网 攒机一时爽,一直攒机一直爽. 沉迷攒机的胡老师很快就发现,他每天只能 ...

  4. CodeForces 604C 【思维水题】`

    题意: 给你01字符串的长度再给你一个串. 然后你可以在这个串中选择一个起点和一个终点使得这个连续区间内所有的位取反. 求: 经过处理后最多会得到多少次01变换. 例如:0101是4次,0001是2次 ...

  5. 思维水题:UVa512-Spreadsheet Tracking

    Spreadsheet Tracking Data in spreadsheets are stored in cells, which are organized in rows (r) and c ...

  6. E - Addition and Subtraction Hard AtCoder - 2273 思维观察题

    http://arc066.contest.atcoder.jp/tasks/arc066_c?lang=en 这类题目是我最怕的,没有什么算法,但是却很难想, 这题的题解是这样的,观察到,在+号里面 ...

  7. 【Gym - 100923A】Por Costel and Azerah(思维水题)

    Por Costel and Azerah Descriptions 给你n个数 问你,有多少个子序列 的和是偶数 Example Input 233 10 124 2 Output 33 题目链接 ...

  8. 【CodeForces - 707B】Bakery(思维水题)

    Bakery Descriptions 玛莎想在从1到n的n个城市中开一家自己的面包店,在其中一个城市烘焙松饼. 为了在她的面包房烘焙松饼,玛莎需要从一些储存的地方建立面粉供应.只有k个仓库,位于不同 ...

  9. 又一道简单题&&Ladygod(两道思维水题)

    Ladygod Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit S ...

随机推荐

  1. 常用yum操作命令

    1.yum repolist 获取当前系统有效的repolist,如下图 2.yum list,列出所有可安装的软件包 获取当前有效repolist中所能安装的所有rpm包列表,(很长,慎重),可以结 ...

  2. P1525 关押罪犯

    基础并查集-- #include<iostream> #include<string.h> #include<algorithm> #include<stdi ...

  3. iOS使用XZMRefresh实现UITableView或UICollectionView横向刷新

    https://blog.csdn.net/u013285730/article/details/50615551?utm_source=blogxgwz6 XZMRefresh The easies ...

  4. Beta阶段冲刺汇总(团队)

    写在前面 汇总成绩排名链接 1.作业链接 第十一次作业--项目Beta冲刺(团队) 2.评分准则 本次作业包括现场Beta答辩评分(映射总分为100分)+博客分(总分120分)+贡献度得分,其中博客分 ...

  5. 接口工具之postman

    在我们日常开发中,经常会对功能接口进行相应的测试.那么postman是一款不错的测试工具,因为平常使用的比较多,因此在这里简单记录一下,经常使用到的一些地方 简单的使用就不错介绍了, 基本流程: 新建 ...

  6. 把composer的源切换为 国际的源

      把composer的源切换为 国际的源:composer config -g repo.packagist composer https://packagist.org

  7. CentOS7 下面安装jdk1.8

    1. 卸载已有的jdk rpm -qa |grep jdk |xargs rpm -e --nodeps 2. 使用xftp上传 jdk 的文件我这里上传的是 jdk-8u121-linux-x64. ...

  8. (三)类数组对象 NamedNodeMap简单介绍

    Ele.attrbutes将返回一个NamedNodeMap对象,即NamedNodeMap存储的是元素的“特性Attribute”集合.而集合中的每一个元素,都是Attr类型的对象. html: & ...

  9. C# Note10: AutoComplete TextBox in WPF

    参考: 1.https://stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf 2.AutoCompleteBox的使用(实现 ...

  10. 牛客练习赛13E 乌龟跑步

    题目链接:https://ac.nowcoder.com/acm/contest/70/E 题目大意: 略 分析: DP或记忆化搜索,个人觉得记忆化搜索比较好做,逻辑清晰,代码量少 代码如下: #in ...