hdu5894 hannnnah_j’s Biological Test
来源:互联网 发布:php九大接口编程 编辑:程序博客网 时间:2024/06/07 18:23
题意:m个人需要坐在有n个座位的圆桌上,使得任意两个人之间距离至少为k,座位都不相同,人可以看做相同
题解:可以想象成每一个人后面至少跟着k个座位
当一个人的位置确定以后,就变成了sum = C(n - 1 - m * k ,m - 1)
因为第一个人选取的位置可能使每一个座位,所以sum * n
因为可能所有人都成为第一个人,所以ans = sum * n / m
LL qpow(LL x,int time){ LL ans=1; while(time){ if(time&1){ ans=ans*x%mod; } x=x*x%mod; time/=2; } 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)*qpow(i,mod-2)%mod)%mod; } return ans;}int n,m,k,t;int main(){ while(cin>>t){ while(t--){ cin>>n>>m>>k; if(m==1){ cout<<n<<endl; } else cout<<(c(n-1-k*m,m-1)*n%mod)*qpow((LL)m,mod-2)%mod<<endl; } } return 0;}
0 0
- hdu5894 hannnnah_j’s Biological Test
- HDU5894-hannnnah_j’s Biological Test【组合数学】
- hdu5894 hannnnah_j’s Biological Test(数学)
- HDU5894-hannnnah_j’s Biological Test(组合数学+Lucas定理)
- hdu5894 hannnnah_j’s Biological Test(组合数学)
- hannnnah_j’s Biological Test
- hdu5894 hannnnah_j’s Biological Test(2016 acm/icpc 沈阳网络赛,组合数学)
- hannnnah_j’s Biological Test HDU
- hannnnah_j’s Biological Test HDU
- hannnnah_j’s Biological Test HDU
- hdu 5894 hannnnah_j’s Biological Test 排列组合
- hdu 5894 hannnnah_j’s Biological Test
- hannnnah_j’s Biological Test (lucas定理 )
- 【HDU5894 2016 ACM ICPC Asia Regional Shenyang Online C】【组合数 隔板法】hannnnah_j’s Biological Test n个不同座位成
- 沈阳网赛1003 HDU 5894 hannnnah_j’s Biological Test
- HDU 5894 hannnnah_j’s Biological Test (组合数学)
- HDU 5894 hannnnah_j’s Biological Test(组合数学)
- HDU 5894 hannnnah_j’s Biological Test 组合数取模
- poj 1011 Sticks
- HDU 2047 - 阿牛的EOF牛肉串(递推)
- [OICamp 2016 Day 1][JZOJ4773]凸包
- C++实现数据结构-队列
- 初识bitset
- hdu5894 hannnnah_j’s Biological Test
- centos6.5环境Redis下载及编译安装
- AngularJS 1.x 和TypeScript(ES6)开发的最佳实践
- IOS手机浏览器无法获取网站视频与音乐,安卓与电脑都可以
- JavaEE之静态,非静态的调用
- 算法16_笔试_数字逻辑推理题2
- C语言函数使用小试牛
- style文件 android window 部分属性说明
- 基础知识之HTTP协议