Iroha and a Grid AtCoder - 1974(思维水题)
就是一个组合数水题
偷个图
去掉阴影部分 把整个图看成上下两个矩形
对于上面的矩形求出起点到每个绿点的方案
对于下面的矩形 求出每个绿点到终点的方案
上下两个绿点的方案相乘后相加 就是了 想想为什么
- #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(思维水题)的更多相关文章
- HDU 2674 N!Again(数学思维水题)
题目 //行开始看被吓一跳,那么大,没有头绪, //看了解题报告,发现这是一道大大大的水题,,,,,//2009 = 7 * 7 * 41//对2009分解,看它有哪些质因子,它最大的质因子是41,那 ...
- HDOJ/HDU 1256 画8(绞下思维~水题)
Problem Description 谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发. Input 输入的第一行为一个整数N,表示后面有N组数据. 每组数据中有一个字符和一 ...
- 2019年华南理工校赛(春季赛)--I--炒股(简单思维水题)
水题,想想就过了 题目如下: 链接:https://ac.nowcoder.com/acm/contest/625/I来源:牛客网 攒机一时爽,一直攒机一直爽. 沉迷攒机的胡老师很快就发现,他每天只能 ...
- CodeForces 604C 【思维水题】`
题意: 给你01字符串的长度再给你一个串. 然后你可以在这个串中选择一个起点和一个终点使得这个连续区间内所有的位取反. 求: 经过处理后最多会得到多少次01变换. 例如:0101是4次,0001是2次 ...
- 思维水题:UVa512-Spreadsheet Tracking
Spreadsheet Tracking Data in spreadsheets are stored in cells, which are organized in rows (r) and c ...
- E - Addition and Subtraction Hard AtCoder - 2273 思维观察题
http://arc066.contest.atcoder.jp/tasks/arc066_c?lang=en 这类题目是我最怕的,没有什么算法,但是却很难想, 这题的题解是这样的,观察到,在+号里面 ...
- 【Gym - 100923A】Por Costel and Azerah(思维水题)
Por Costel and Azerah Descriptions 给你n个数 问你,有多少个子序列 的和是偶数 Example Input 233 10 124 2 Output 33 题目链接 ...
- 【CodeForces - 707B】Bakery(思维水题)
Bakery Descriptions 玛莎想在从1到n的n个城市中开一家自己的面包店,在其中一个城市烘焙松饼. 为了在她的面包房烘焙松饼,玛莎需要从一些储存的地方建立面粉供应.只有k个仓库,位于不同 ...
- 又一道简单题&&Ladygod(两道思维水题)
Ladygod Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit S ...
随机推荐
- eclipse maven设置
eclipse 4.4以上版本集成了maven,只需配置一下即可,如果你的eclipse 没有安装maven,可以参考这个文章.http://marketplace.eclipse.org/conte ...
- C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 即时消息提醒功能改进
可以给自己的信息管理系统增加一些即时消息提醒功能,简单方便,一般是一行代码就可以发送提醒信息了,方便二次开发,个性化改进. 1:可以用简拼,快速查找内部员工. 2:双击直接可以发QQ消息. 3:双击直 ...
- elasticsearch(6.2.3)安装Head插件
一.安装elasticsearch,参照:https://www.cnblogs.com/dyh004/p/8872443.html 二.安装nodejs,参照:https://www.runoob. ...
- Dockerfile cnetos7_nginx1.15.10
FROM centos:7 MAINTAINER yuyongxr yuyongxr@gmail.com LABEL Discription="centos7+nginx1.15.10&qu ...
- 二十一、当锚点遇到fixed(margin和padding)
当锚点点击跳转的时候,如果上方有fixed,锚点跳转会默认跳转到top为0的地方,有一部分就被遮挡了 解决方法:(像素值随便给的) 给锚点跳转到的具体内容加padding-top:-50px:marg ...
- python3 pip 安装Scrapy在win10 安装报错error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
问题描述 当前环境win10,python_3.6.1,64位. 在windows下,在dos中运行pip install Scrapy报错: building 'twisted.test.raise ...
- ElasticSearch(简称ES)
Windows下安装ElasticSearch ElasticSearch(简称ES)是一个基于Lucene的分布式全文搜索服务器,和SQL Server的全文索引(Fulltext Index) ...
- springboot的几种启动方式
一:IDE 运行Application这个类的main方法 二:在springboot的应用的根目录下运行mvn spring-boot:run 三:使用mvn install 生成jar后运行 先到 ...
- Centos6.8 安装nginx
1.安装相关依赖 (1)yum install gcc 备注:可以通过gcc -v 查看版本信息,来确定是否安装过. (2)yum install pcre-devel (3)yum install ...
- RabbitMQ在Ubuntu 16.04下的安装与配置
安装执行如下命令: echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d ...