51nod 1627 瞬间移动【组合数学】
来源:互联网 发布:asm算法原理 编辑:程序博客网 时间:2024/05/20 18:20
Description
有一个无限大的矩形,初始时你在左上角(即第一行第一列),每次你都可以选择一个右下方格子,并瞬移过去(如从下图中的红色格子能直接瞬移到蓝色格子),求到第n行第m列的格子有几种方案,答案对1000000007取模。
题解
枚举走的步数,直接搞。
代码
#include<cstdio>#include<cstring>#include<algorithm>#define tt 1000000007#define maxn 100006#define LL long longusing namespace std;int n,m;LL ans,f[maxn*2],inv[maxn*2];LL power(LL x,int y){ if(!y)return 1; if(y==1)return x%tt; LL c=power(x,y>>1); if(y&1)return c*x%tt*c%tt; else return c*c%tt;}LL C(int x,int y){return f[x]*inv[x-y]%tt*inv[y]%tt;}int main(){ freopen("teleport.in","r",stdin); freopen("teleport.out","w",stdout); scanf("%d%d",&n,&m); f[0]=1;inv[0]=1; for(int i=1;i<=n+m;i++)f[i]=f[i-1]*i%tt,inv[i]=power(f[i],tt-2); for(int i=0;i<=min(n,m)-2;i++)(ans+=C(n-2,i)*C(m-2,i)%tt)%=tt; printf("%lld\n",ans); return 0;}
阅读全文
0 0
- 51nod 1627 瞬间移动【组合数学】
- 51nod 瞬间移动 (组合数学)
- 51nod 1627 瞬间移动 组合数取模
- 【组合数】51Nod 1627 瞬间移动
- 51nod 1627 瞬间移动 组合数
- 51nod 1627 瞬间移动
- 51nod 1627 瞬间移动
- 【组合数学】HDU5698[瞬间移动]题解
- 百度之星-瞬间移动 组合数学逆元
- 51node-1627 瞬间移动
- 51nod 1228 (伯努利数 + 组合数学)
- 51Nod - 1677 树形dp + 组合数学
- Hdu 5698 瞬间移动【组合+逆元】
- hdu 5698 瞬间移动 -- (大组合数取模)
- 大组合数取模hdu5698 瞬间移动
- 51NOD 1639 绑鞋带(组合数学 + 递推)
- 51nod 1118 机器人走方格(组合数学)
- 51nod-1509 加长棒(组合数学+挡板法)
- SpringMVC上传文件的三种方式
- 一些常用的插件(也许会随时补充)
- 关于原生js的一些研究
- 学习JavaScript
- 628. Maximum Product of Three Numbers
- 51nod 1627 瞬间移动【组合数学】
- js中把new Date().getTime()时间戳转化成日期类型
- 自信的作用
- Mint UI -- 基于Vue.js的移动端组件库
- 【jquery】选择器
- 解析Json之MappingJackson2HttpMessageConverter使用方法
- Autohotkey 组合键与序列键的定义
- BZOJ1076 奖励关 期望dp+状压
- Missing Marketing Icon. iOS Apps must include a 1024x1024px Marketing Icon in PNG format. Apps that