Codeforces Beta Round #95 (Div. 2) C. The World is a Theatre 组合数学
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.
The only line of the input data contains three integers n, m, t (4 ≤ n ≤ 30, 1 ≤ m ≤ 30, 5 ≤ t ≤ n + m).
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.
- 5 2 5
- 10
- 4 3 5
- 3
思路:在4个男生1个女生的基础上暴力求组合数;不好描述见代码;
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<string>
- #include<queue>
- #include<algorithm>
- #include<stack>
- #include<cstring>
- #include<vector>
- #include<list>
- #include<set>
- #include<map>
- using namespace std;
- #define ll long long
- #define inf 2000000001
- int scan()
- {
- int res = , ch ;
- while( !( ( ch = getchar() ) >= '' && ch <= '' ) )
- {
- if( ch == EOF ) return << ;
- }
- res = ch - '' ;
- while( ( ch = getchar() ) >= '' && ch <= '' )
- res = res * + ( ch - '' ) ;
- return res ;
- }
- ll combine1(ll n,ll m) //计算组合数C(n,m)
- {
- ll sum=; //线性计算
- for(ll i=,j=n;i<=m;i++,j--)
- sum=sum*j/i;
- return sum;
- }
- int main()
- {
- ll x,y,z,i,t;
- scanf("%I64d%I64d%I64d",&x,&y,&z);
- int b=,g=z-;
- ll ans=;
- for(i=;i<=x;i++)
- {
- b=i;
- g=z-i;
- if(g>y||g<)continue;
- ans+=combine1(x,b)*combine1(y,g);
- }
- cout<<ans<<endl;
- return ;
- }
Codeforces Beta Round #95 (Div. 2) C. The World is a Theatre 组合数学的更多相关文章
- Codeforces Beta Round #95 (Div. 2) D.Subway
题目链接:http://codeforces.com/problemset/problem/131/D 思路: 题目的意思是说给定一个无向图,求图中的顶点到环上顶点的最短距离(有且仅有一个环,并且环上 ...
- codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)
题目链接:http://www.codeforces.com/problemset/problem/131/A题意:字符串大小写转换.C++代码: #include <cstdio> #i ...
- Codeforces Beta Round #95 (Div. 2) D. Subway dfs+bfs
D. Subway A subway scheme, classic for all Berland cities is represented by a set of n stations conn ...
- Codeforces Beta Round #95 (Div. 2) C 组合数学
C. The World is a Theatre time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces Beta Round #95 (Div. 2) D. Subway 边双联通+spfa
D. Subway A subway scheme, classic for all Berland cities is represented by a set of n stations co ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
随机推荐
- Hadoop集群安装-CDH5(5台服务器集群)
CDH5包下载:http://archive.cloudera.com/cdh5/ 架构设计: 主机规划: IP Host 部署模块 进程 192.168.254.151 Hadoop-NN-01 N ...
- win 7 和 winserver 2008 下,布署网站遇到的错误解决方法
本人亲测,有效. 1.如果只列出目录: web.config的system.webServer配置节下是否有这个: <modules runAllManagedModulesForAllRequ ...
- Qt界面控件值获取异常处理
情景简述: 正常情况,我们从控件获取的值是OK的,但有时候就是奇怪的不对头,那么我们可以给获取后的值加上一个不痛不痒的函数,再返回,结果就OK了.至于原因嘛,[呲牙][呲牙] 比如: //正常情况 d ...
- 安卓备份 To Do(待办事项)的数据库
真正路径:/data/data/com.mediatek.todos/databases/todos.db 使用过链接的路径:/data/user/0/com.mediatek.todos/datab ...
- Junit4用法
序号 方法和描述 1 void assertEquals(boolean expected, boolean actual) 检查两个变量或者等式是否平衡 2 void assertTrue(bool ...
- JNDI—目录接口名
1:什么是JNDI? Java名称与目录接口:java Naming and Directory Interface未开发人员提供的查找和访问各种名称和目录的 服务和接口 2:全局的上下文配置文件: ...
- 数据仓库基础(二)ETL
本文转载自:http://www.cnblogs.com/evencao/archive/2013/06/14/3135529.html ETL在数据仓库中具有以下的几个特点: 数据流动具有周期性: ...
- Linux基础命令---shutdown
shutdown shutdown指令以安全的方式来关闭系统,所有已经登录的用户都会被告知系统将要关闭.并且在最后五分钟内,新的登录将被阻止.过了指定的time后,关机会向init(8)守护进程发送一 ...
- schema与catalog的理解
sql环境中Catalog和Schema都属于抽象概念,主要用来解决命名冲突问题.一个数据库系统包含多个Catalog,每个Catalog包含多个Schema,每个Schema包含多个数据库对象(表. ...
- python的时间处理-time模块
time模块 时间的表示方法有三种: 时间戳:表示的是从1970年1月1日0点至今的秒数 格式化字符串表示:这种表示更习惯我们通常的读法,如2018-04-24 00:00:00 格式化元祖表示:是一 ...