E - The World is a Theatre
来源:互联网 发布:网络医疗咨询平台 编辑:程序博客网 时间:2024/06/06 03:53
Description
There are n boys and m girls attending a theatre club. To set a play "The Big Bang Theory", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the composition of the troupe are considered different.
Perform all calculations in the 64-bit type: long long for С/С++, int64 for Delphi and long for Java.
Input
The only line of the input data contains three integers n, m, t (4 ≤ n ≤ 30, 1 ≤ m ≤ 30, 5 ≤ t ≤ n + m).
Output
Find the required number of ways.
Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.
Sample Input
5 2 5
10
4 3 5
3
小结:
感觉想法和划分数差不多....大概的想法是,DP[i][j]表示从i中取j个的取法,这里的i,j个物品没有区别。
然后就有状态转移方程DP[i][j]=DP[i-1][j]+DP[i-1][j-1].
以下是AC代码:
#include<stdio.h>
#include<string.h>
int main()
{
int n,m,t;
scanf("%d%d%d",&n,&m,&t);
long long dp[65][65];
memset(dp,0,sizeof(dp));
for(int i=0;i<=30;i++)
{
dp[i][0]=1;
for(int j=1;j<=i;j++)
{
dp[i][j]=dp[i-1][j]+dp[i-1][j-1];
}
}
long long ans=0;
for(int i=4;i<t;i++)
{
ans+=dp[n][i]*dp[m][t-i];
}
printf("%lld\n",ans);
return 0;
}
- E - The World is a Theatre
- E - The World is a Theatre
- The World is a Theatre
- C. The World is a Theatre
- The World is a Theatre codeforces131c
- CodeForces 131C The World is a Theatre 组合数
- Codeforces Beta Round #95 (Div. 2)C. The World is a Theatre
- Codeforces Beta Round #95 (Div. 2) C The World is a Theatre(组合数)
- The world is flat
- tn gives the first impression is that it is not a world
- The world is not enough
- CODEFORCES:A. Theatre Square
- A. Theatre Square
- Going to a Theatre
- 1A. Theatre Square
- 1A--Theatre Square
- 1A - Theatre Square
- 1A. Theatre Square
- 【工作技巧】注册Windbg为默认调试器的方法
- WebView注入Java对象注意事项
- Q13.cocoapod_卡在“analyzing_depengcies”问题解决
- 南娜精油皂,看得见未来的美!
- SparseArray替代HashMap来提高性能
- E - The World is a Theatre
- day11-mytag&jst&i18nのPPTの学习2
- 浮雕,雕刻,木刻,灯光,油画滤镜的原理及实现 opencv+vs
- 所谓的时间以及进步改变
- Unity3D游戏开发教程 链接
- CANopen学习笔记
- day11-mytag&jst&i18nのPPT学习3
- Can总线上的电平及物理层仲裁
- LeetCode_3Sum