hdu5698瞬间移动(组合数,逆元)
瞬间移动
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1422 Accepted Submission(s):
684
行第m
列的格子有几种方案,答案对1000000007
取模。
两个整数n,m(2≤n,m≤100000)

#include<iostream>
#include<cstdio>
#include<cstring> #define N 200001
#define M 1000000007
#define ll long long using namespace std;
ll fac[N]={,},inv[N]={,},f[N]={,};
int n,m; ll C(ll a,ll b)
{
return fac[a]*inv[b]%M*inv[a-b]%M;
} int main()
{
for(int i=;i<N;i++)
{
fac[i]=fac[i-]*i%M;
f[i]=(M-M/i)*f[M%i]%M;
inv[i]=inv[i-]*f[i]%M;
}
while(~scanf("%d%d",&n,&m)) printf("%lld\n",C(m+n-,m-));
return ;
}
hdu5698瞬间移动(组合数,逆元)的更多相关文章
- hdu5698瞬间移动-(杨辉三角+组合数+乘法逆元)
瞬间移动 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- hdu5698瞬间移动(杨辉三角+快速幂+逆元)
瞬间移动 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- 【HDU 5698】瞬间移动(组合数,逆元)
x和y分开考虑,在(1,1)到(n,m)之间可以选择走i步.就需要选i步对应的行C(n-2,i)及i步对应的列C(m-2,i).相乘起来. 假设$m\leq n$$$\sum_{i=1}^{m-2} ...
- 51nod-1627 瞬间移动(组合数+逆元)
题目描述: 有一个无限大的矩形,初始时你在左上角(即第一行第一列),每次你都可以选择一个右下方格子,并瞬移过去(如从下图中的红色格子能直接瞬移到蓝色格子),求到第n行第m列的格子有几种方案,答案对10 ...
- HDU 5698——瞬间移动——————【逆元求组合数】
瞬间移动 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- NOIP2011多项式系数[快速幂|组合数|逆元]
题目描述 给定一个多项式(by+ax)^k,请求出多项式展开后x^n*y^m 项的系数. 输入输出格式 输入格式: 输入文件名为factor.in. 共一行,包含5 个整数,分别为 a ,b ,k , ...
- 2016 ACM/ICPC Asia Regional Shenyang Online 1003/HDU 5894 数学/组合数/逆元
hannnnah_j’s Biological Test Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K ...
- hdu-5698 瞬间移动(数论+快速幂)
题目链接: 瞬间移动 Problem Description 有一个无限大的矩形,初始时你在左上角(即第一行第一列),每次你都可以选择一个右下方格子,并瞬移过去(如从下图中的红色格子能直接瞬移到蓝 ...
- Gym - 101775A Chat Group 组合数+逆元+快速幂
It is said that a dormitory with 6 persons has 7 chat groups ^_^. But the number can be even larger: ...
随机推荐
- MAC 打开Chrome打开开发者工具的快捷键
mac下safari和chrome打开开发者工具的快捷键相同,都是 option(alt)+command+i 这个是我的默认配置,没有更改过的.
- 关于图片预览使用base64在chrome上的性能问题解决方法
在开发后台上传图片的功能时候使用base64预览图片,结果在传入大量图片后导致chrome崩溃,代码如下 var img = new Image(); var render = new FileRea ...
- Vue.Draggable实现拖拽效果(采坑小记)
之前有写过Vue.Draggable实现拖拽效果(快速使用)(http://www.cnblogs.com/songdongdong/p/6928945.html)最近项目中要用到这个拖拽的效果,当产 ...
- 矩形面积求并(codevs 3044)
题目描述 Description 输入n个矩形,求他们总共占地面积(也就是求一下面积的并) 输入描述 Input Description 可能有多组数据,读到n=0为止(不超过15组) 每组数据第一行 ...
- 【驱动开发】file_operations ---linux 2.6.30
路径: linux-2.6.30/include/linux/fs.h struct file_operations { struct module *owner; loff_t ...
- Calculate S(n)
Problem Description Calculate S(n). S(n)=13+23 +33 +......+n3 . Input Each line will contain one i ...
- 玲珑杯 ACM Round #12
A =w= B 占坑 C 题意:有长度为n的序列A和长度为n的序列W,以及一个G,对于Ui,1<=Ui<=Wi,求Σgcd(Ai,Ui)=G的方案数,n<=1e3,Ai<=1e ...
- jd-eclipse插件的安装
一,资源 jd-eclipse-site-1.0.0-RC2.zip 百度网盘链接:https://pan.baidu.com/s/1GTFFY_1jg4k9vjZNE4JliQ 提 ...
- 定义Portal显示规则
Defining Portal Display Rules Use You use the Portal Display Rules editor to create and edit rule co ...
- tapset::iosched(3)
DESCRIPTION This family of probe points is used to probe the IO scheduler activities. It contains th ...