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;
}