hdu 6114 Chess
来源:互联网 发布:张子枫清华附中知乎 编辑:程序博客网 时间:2024/06/08 07:03
这个题很容易看出规律,就是求c(n,m),if(n<m)swap(n,m)
用的模板
#include<algorithm>#include <iostream>#include <stdlib.h>#include <string.h>#include <stdio.h>#include <math.h>#include <time.h>#include <vector>#include <bitset>#include <queue>#include <set>#include <map>using namespace std;long long p,m,n;long long Pow(long long a,long long b) {long long ans=1;while(b) {if(b&1) {b--;ans=(ans*a)%p;} else {b/=2;a=(a*a)%p;}}return ans;}long long C(long long n,long long m) {if(n<m)return 0;long long ans=1;for(int i=1; i<=m; i++) {ans=ans*(((n-m+i)%p)*Pow(i,p-2)%p)%p;}return ans;}long long Lucas(long long n,long long m) {if(m==0)return 1;return Lucas(n/p,m/p)*C(n%p,m%p)%p;}int main(){ int t; p=1000000000+7; scanf("%d",&t); while(t--) { int n,m; scanf("%d%d",&n,&m); if(n>m) { int t; t=n; n=m; m=t; } cout<<Lucas(m,n)<<endl; } return 0;}
阅读全文
0 0
- hdu 6114 Chess
- 【HDU 6114 Chess】
- HDU 6114 Chess
- HDU 6114 Chess【组合数学】
- HDU 6114 Chess【Lucas定理】
- Chess HDU
- Chess HDU
- Chess HDU
- HDU 6114 Chess (组合数 思路)
- HDU 6114 Chess(组合数学)
- HDU 3004 the chess
- hdu 4405 Aeroplane chess
- hdu 4405 Aeroplane chess
- HDU 4405 Aeroplane chess
- hdu 1691 Chinese Chess
- hdu 3345 War Chess
- HDU 3026 Chinese Chess
- hdu 4405 Aeroplane chess
- Spark Standalone架构设计要点分析
- 搭建SSM项目框架全过程及思考
- VB循环
- [(ngModel)]的实现原理
- Android 自定义弹出菜单和对话框
- hdu 6114 Chess
- mysql group_concat 分组,多字段统一排序及输出数据到java
- Java Servlet完全教程
- struts2--自定义校验器
- Eclipse报错Could not resolve archetype
- 扩增子分析解读6进化树,Alpha,Beta多样性
- 菜鸟学习大数据技术的过程
- request.getSession(true)和request.getSession(false)的区别
- IDA 汇编命令分析以及函数调用过程