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 ...
随机推荐
- SqlServer2000事件探测器的使用
由于公司自己开发的项目,需要与第三方软件数据库对接.我们项目用的数据库是MySQL而第三方用的是sqlserver2000.项目框架用的thinkphp5.0,通过thinkPHP新建一个模块,单独连 ...
- 使用jquery实现获取除this(当前选定)以外的元素
今天做项目时,要求完成功能评价的分类,即好评,差评,中评.遇到一个问题,如何在选定一个评论类型时,该div颜色改变,其他评论类型的div颜色不变. 在使用$(this).attr()时,表示当前元素的 ...
- ES6 Reflect使用笔记
Reflect Reflect 对象和Proxy对象一样, 为操作对象提供了新的API. 为什么使用 Reflect的方式来操作对象? 将 Object 对象上一些明显属于内部的方法放到 Reflec ...
- vue项目各页面间的传值
githut地址:https://github.com/liguoyong/vueobj1 一.父子之间主键传值:(主要是在父主件里的子主件传递参数,然后再子主件里用props接收) 例如Father ...
- .NET下寄宿于控制台的HTTPS监听
附上原文链接:https://blogs.msdn.microsoft.com/jpsanders/2009/09/29/how-to-walkthrough-using-httplistener-o ...
- shell 流水账
在shell脚本运行时,会先查找系统环境变量ENV,该变量指定了环境文件(加载顺序通常是/etc/profile ~/.bash_profile ~/.bashrc /etc/bashrc) 设置全局 ...
- JavaScript ES6功能概述(ECMAScript 6和ES2015 +)
JavaScript在过去几年中发生了很大的变化.这些是您今天可以开始使用的12项新功能! 该语言的新增内容称为ECMAScript 6.它也称为ES6或ES2015 +. 自1995年JavaScr ...
- Python循环的一些基本练习
#1:# name = input('请输入你的身份')# if name == 'egon':# print('--> 超级管理员')# elif name == 'tom':# print( ...
- (转)iOS 对矢量图片的支持如何?
简单说,iOS 支持矢量图片,不过支持的一般.在系统层面上,iOS 对矢量绘图支持得很好.iOS 的 Core Graphics 框架带有很多矢量绘图命令,简单一些的直线.矩形.椭圆,复杂一些的贝赛尔 ...
- Essential C++ 3.1 节的代码练习——指针方式
// // PointerToValue.cpp // Working // // Created by Hawkins, Dakota Y on 6/3/16. // Copyright 2016 ...