c语言 组合数学+大数取模
来源:互联网 发布:手机怎么切换软件 编辑:程序博客网 时间:2024/06/05 03:40
//hdu5894
#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<cstdio>#include<string>#include<set>#include<map>#include<queue>#include<stack>using namespace std;#define LL long long#define N 1000000009#define cl(a,b) memset(a,b,sizeof(a))const int mod=1000000007;LL pow_mod(LL a,int n){ LL ans=1; while(n) { if(n&1)ans=ans*a%mod; a=a*a%mod; n>>=1; } return ans;}LL C(int n,int m){ if(m>n)return 0; LL ans=1; for(int i=1;i<=m;i++) ans=ans*((n+i-m)*pow_mod(i,mod-2)%mod)%mod; return ans;}int main(){ int t; LL n,m,k; scanf("%d",&t); while(t--) { scanf("%I64d%I64d%I64d",&n,&m,&k); if(m==1)printf("%I64d\n",n); else printf("%I64d\n",(C(n-k*m-1,m-1)*n%mod)*pow_mod(m,mod-2)%mod);//C*n/m除号改成*pow_mod(m,mod-2) } return 0;}
1 0
- c语言 组合数学+大数取模
- C语言实现 组合数学 生成组合序列
- HDU4675【GCD of scequence】【组合数学、费马小定理、取模】
- hdu 6036 NTT取模(板子)+组合数学
- 编程优化数学组合排列公式取模实现
- C语言实现数学上的组合和排列
- 组合数学 字典序法生成序列C语言实现
- C语言实现组合数学 邻位互换生成算法
- 博弈论 NIM取子问题 组合数学
- 大数取模运算
- 大数取模
- 大数取模
- 大数取模 poj2635
- 大数取模模板
- 1086:大数取模
- hdu1212(大数取模)
- 大数取模
- java大数取模
- requireJs进行模块化开发
- 编写脚本和批处理
- TTNavigationBar-alpha 导航栏隐藏渐变
- 关于指针作为函数参数的一些想法
- 通过 Hibernate 实现 JPA 对象关系模型之继承映射策略
- c语言 组合数学+大数取模
- 时间选择器
- 关于安卓app开发中与EditText相关的输入法(软键盘)隐藏问题的解决方案
- C#对象序列化与反序列化
- 0036-Document
- AJAX工作原理及其优缺点
- The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
- MySQL客户端输出窗口显示中文乱码问题解决办法
- Atitit org.eclipse.jdt 的ast 架构 Eclipse JDT API spec