博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The World is a Theatre(组合数学)
阅读量:4134 次
发布时间:2019-05-25

本文共 1433 字,大约阅读时间需要 4 分钟。

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.

Examples

Input
5 2 5
Output
10
Input
4 3 5
Output
3
挺水的这道题,但是一次做对也不是很容易。首先打表求出组合数。其次数组不要开得太小,dp[i][j],如果j>i的时候,就是0。
代码如下:

#include
#define ll long longusing namespace std;const int maxx=100;int n,m,t;ll dp[maxx][maxx];inline void init(){
memset(dp,0,sizeof(dp)); for(int i=0;i<=30;i++) {
dp[0][i]=0; dp[i][0]=1ll; } for(int i=1;i<=30;i++) {
for(int j=1;j<=i;j++) {
dp[i][j]=(dp[i-1][j]+dp[i-1][j-1]); } }}int main(){
init(); while(~scanf("%d%d%d",&n,&m,&t)) {
if(t<5||n<4||m<1) puts("0"); else {
ll sum=0; for(int i=4;i<=n&&t-i>=1;i++) {
sum+=dp[n][i]*dp[m][t-i];//单纯的排列组合 } printf("%I64d\n",sum); } }}

努力加油a啊,(o)/~

转载地址:http://bytvi.baihongyu.com/

你可能感兴趣的文章
程序员笔试面试常见题总结,更新ing
查看>>
阿里笔试--软开C/C++
查看>>
腾讯笔试--移动客户端软件开发工程师
查看>>
360在线测试--嵌入式软开
查看>>
优化程序性能—《深入理解计算机系统》
查看>>
《演讲的艺术》有感
查看>>
《亲密关系》摘录
查看>>
win7下安装centOS7双系统
查看>>
Linux鸟哥的私房菜—1
查看>>
matlab 批处理图片
查看>>
每日总结-1
查看>>
python学习之 打包脚本
查看>>
Android开发华为手机无法看log日志解决方法
查看>>
Android 关于在Activity中监听ListView
查看>>
Android xUtils3.0使用手册(二) - 数据库操作
查看>>
护眼颜色设置
查看>>
Android RecyclerView体验(一)- 简介
查看>>
Android tools:context=".MainActivity"的作用
查看>>
Android ListView多布局讲解
查看>>
Android 权限管理
查看>>