hdu 4504 威威猫系列故事——篮球梦

原文链接: http://www.cnblogs.com/liulangye/archive/2013/03/23/2976884.html

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

dp也可以  组合也可以

下面是组合代码:

#include<iostream>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>

#define LL long long

using namespace std;

const int INF=0x3f3f3f3f;
const int MOD=100000;
const LL LMOD=100000;
const int N=105;
const int M=105;
const int K=6;
LL C(int n,int m)
{
    LL tmp=1;
    for(int i=n-m+1;i<=n;++i)
    {
        tmp=tmp*i;
        while(m>=1&&tmp%m==0)
        {
            tmp=tmp/m;
            --m;
        }
    }
    return tmp;
}
int main()
{
    //freopen("data.in","r",stdin);
    int T,A,B;
    while(scanf("%d %d %d",&A,&B,&T)!=EOF)
    {
       int need=(T/15/2+B-A);
       int n=(T/15+1)/2;
       LL sum=0;
       for(int i=0;i<=n;++i)
       for(int j=0;j<=n;++j)
       {
          if(i+j*2+(n-i-j)*3>need)
          {
             sum+=(C(n,i)*C(n-i,j));
          }
       }
       cout<<sum<<endl;
    }
    return 0;
}

  

转载于:https://www.cnblogs.com/liulangye/archive/2013/03/23/2976884.html

猜你喜欢

转载自blog.csdn.net/weixin_30919429/article/details/94791850