首页 > 其他 > 详细

【组合数模板】HDU 6114 Chess

时间:2017-08-13 19:05:49      阅读:283      评论:0      收藏:0      [点我收藏+]

http://acm.hdu.edu.cn/showproblem.php?pid=6114

【思路】

就是求C(m,n)

【板】

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
const int maxn=1e3+2;
int n,m;
ll C[maxn][maxn];
const ll mod=1e9+7;
void init()
{
    C[0][0]=1;
    for (int i=0;i<maxn;i++)
    {
        C[i][0]=1;
        for (int j=1;j<=i;j++)
        {
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
} 
int main()
{
    init();    
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d%d",&n,&m);
        if(n>m) swap(n,m);
        ll ans=C[m][n];
        cout<<ans<<endl; 
    }
    return 0;
}

 

【组合数模板】HDU 6114 Chess

原文:http://www.cnblogs.com/itcsl/p/7354325.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!