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 ...
随机推荐
- P2P平台介绍
https://www.ludou.org/tutengdai.html https://www.tutengdai.com/register?invite_code=9991300
- 设计模式之单例模式(C#)
本文来自于本人个人微信公众号,欢迎关注本人微信公众号,二维码附在文章末尾~~~ 一直都特别羡慕能写文章的人,但是由于本人比较懒再加上写文章功底实在是just so so,所以就一搁再搁,最近突然觉得自 ...
- Python_匿名函数_47
匿名函数 Eva_J 匿名函数:为了解决那些功能很简单的需求而设计的一句话函数 #这段代码 def calc(n): return n**n print(calc(10)) #换成匿名函数 calc ...
- mybatis 的sql语句及使用mybatis的动态sql mybatis防注入
由于看到写的比较详细的文档这里将之前的删掉了,只留下一些我认为能帮助理解的和关于动态sql及防注入的一些理解.文档链接 :mybatis官方文档介绍 <!-- 根据条件查询用户 --> ...
- Python—re模块
re模块 正则表达式就是字符串的匹配规则,在多数编程语言里都有相应的支持,python里对应的模块是re 常用的表达式规则 '.' 默认匹配除\n之外的任意一个字符,若指定flag DOTALL,则匹 ...
- ARC 066D Xor Sum AtCoder - 2272 (打表找规律)
Problem Statement You are given a positive integer N. Find the number of the pairs of integers u and ...
- 不能再忽视了!宝宝不肯吃粥的N个原因,你避免了几个?
辅食不懂怎么添加? 宝宝吃饭爱挑食? 营养均衡和多样化的辅食 在这里你都能找到 宝宝辅食微课堂 不能再忽视了!宝宝不肯吃粥的N个原因,你避免了几个? 2017-10-09 09:35 辅食不懂怎么添加 ...
- 结对项目3-功能增强型带基本函数计算java计算器
-----------------------------------------------------实验报告------------------------------------------- ...
- 03-命令图片.doc
- js总结:三级联动
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...