Codeforces Beta Round #95 (Div. 2) C 组合数学
2 seconds
256 megabytes
standard input
standard output
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 题意:n个男生 m个女生 选t个人 男生最少4个 女生最少1个 问有多少种选择方式 题解:组合数学 数据范围很小 求组合数 直接公式线性处理或者杨辉三角处理 C(n,m)=n!/m!(n-m)!
注意在男生为4,女生为1的基础上暴力求。枚举男生的人数i=(4~t-1)ΣC(n,i)*C(m,t-i)
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll long long
using namespace std;
ll n,m,t;
ll ans;
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()
{
scanf("%I64d %I64d %I64d",&n,&m,&t);
for(int i=;i<=t-;i++)
{
ans=ans+combine1(n,i)*combine1(m,t-i);
}
printf("%I64d\n",ans);
}
Codeforces Beta Round #95 (Div. 2) C 组合数学的更多相关文章
- Codeforces Beta Round #95 (Div. 2) C. The World is a Theatre 组合数学
C. The World is a Theatre There are n boys and m girls attending a theatre club. To set a play " ...
- 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) 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 ...
随机推荐
- C#获取Honeywell voyager 1400g扫码后的数据
一.在类方法中加入 System.IO.Ports.SerialPort com;二.在构造方法中加入 try { com = new System.IO.Ports.SerialPort(&qu ...
- python内置函数map/reduce/filter
python有几个内置的函数很有意 思:map/filter/reduce,都是对一个集合进行处理,filter很容易理解用于过滤,map用于映射,reduce用于归并. 是python列表方法的三架 ...
- 简述在php中 = 、==、 === 的区别(简述在php中 等于 、双等于、 三等于 的区别)
= 是赋值:就是说给一个变量赋值 == 是轻量级的比较运算,只看值不看类型 === 是重量级的比较运算,既看值,也看类型,要绝对相等才会为true
- Bank Simulation Program银行管理系统C++ :)
设计并实现简单的银行存取款系统,系统主界面包括登录和注册两个选项,选择登录,提示用户输入银行帐号和密码,验证通过后进入主界面,主界面包括:存款.取款.查询余额.历史记录.修改密码等功能.注册功能让用户 ...
- 科学计算库Numpy——数值计算
矩阵 求和 乘积 最大值和最小值 最大值和最小值的位置 平均数 标准差 方差 限制 四舍五入
- Git-Git初始化
创建版本库及第一次提交 通过如下操作来查看一下您的Git版本. $ git --version git version 1.7.4 在开始 Git 之旅之前,我们需要设置一下 Git 的配置变量,这是 ...
- 商品评分效果JavaScript
<script> window.onload=function(){ //----------选中的星星会多出一个属性:isClick="true" 藉此来获取评分-- ...
- Beats、Filebea入门
1. Filebeat配置简介 2. Filebeat收集nginx日志 3. packetbeat简介与演示
- cf979d Kuro and GCD and XOR and SUM
set做法 正解是trie-- 主要是要学会 \(a\ \mathrm{xor}\ b \leq a+b\) 这种操作 #include <iostream> #include <c ...
- python拼接
拼接: name=zhuhuan age=23 salary=333 info=''' ----- info of %s----- age:%s name:%s salary:%s %(name,ag ...