51nod 1627 瞬间移动
来源:互联网 发布:笨办法学python习题26 编辑:程序博客网 时间:2024/05/03 09:56
ans=sum( C(n-2,i) * C(m-2,i) )
然后求下逆元就好了。
#include<bits/stdc++.h>using namespace std;const long long mod=1e9+7;const int MAXN=100100;long long fac[MAXN],inv[MAXN];long long powmod(long long x,long long p){long long ret=1;while(p){if(p&1)ret=ret*x%mod;x=x*x%mod;p>>=1;}return ret;}long long C(long long n,long long m){if(m>n)return 0;return fac[n]*inv[n-m]%mod*inv[m]%mod;}int main(){long long n,m,i,ans;fac[0]=inv[0]=1;for(i=1;i<MAXN;i++){fac[i]=i*fac[i-1]%mod;inv[i]=powmod(fac[i],mod-2);}while(~scanf("%lld%lld",&n,&m)){ans=0;for(i=0;i<=min(n,m)-2;i++)ans=(ans+C(n-2,i)*C(m-2,i)%mod)%mod;printf("%lld\n",ans);}}
0 0
- 51nod 1627 瞬间移动
- 51nod 1627 瞬间移动
- 51nod 1627 瞬间移动 组合数取模
- 51nod 1627 瞬间移动【组合数学】
- 【组合数】51Nod 1627 瞬间移动
- 51nod 1627 瞬间移动 组合数
- 51nod 瞬间移动 (组合数学)
- 51node-1627 瞬间移动
- 51 mod P1627 瞬间移动 排列组合
- HDU 5698 瞬间移动
- HDU 5698 瞬间移动
- 排列组合 hdu5698 瞬间移动
- HDU 5698 瞬间移动
- hdu5698瞬间移动
- hdu5698 瞬间移动
- HDU 5698-瞬间移动
- 瞬间移动(c(n, m))
- hdoj 瞬间移动 5698(逆元)
- Atitit图像识别的常用特征大总结attilax大总结
- Android/Java回调理解
- Histogram of Oriented Gridients(HOG) 方向梯度直方图
- Java有没有goto关键字?
- springmvc 集成apache cxf 开发webservice 示例
- 51nod 1627 瞬间移动
- 倒计时设置
- 在单片机上点亮LED
- java enum枚举
- Cassandra 3.x官方文档_DataStax Distribution of Apache Cassandra 3.x有哪些新特性?
- SpringMVC学习笔记(五)
- 系统调用和库函数的区别
- 广工2016新生决赛 H《为什么会变成这样呢》 [位运算]【思维】【好题】
- Oracle数据泵技术导入导出