(以“分类:组合数学 ==摘要== {{信息题|The World is a Theatre|http://acm.hust.edu.cn/vjudge/contest/view.action?cid{{=}}70200#problem/I|2|100|遗漏情况|4|...”为内容创建页面) |
小 (→摘要: 难度) |
||
| 第1行: | 第1行: | ||
[[分类:组合数学]] | [[分类:组合数学]] | ||
==摘要== | ==摘要== | ||
| − | {{信息题|The World is a Theatre|http://acm.hust.edu.cn/vjudge/contest/view.action?cid{{=}}70200#problem/I| | + | {{信息题|The World is a Theatre|http://acm.hust.edu.cn/vjudge/contest/view.action?cid{{=}}70200#problem/I|1|100|遗漏情况|4|time=2015-02-14 15:52:05}} |
*来自寒假练习:[http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70200 Special Round for Valentine's Day] I题 | *来自寒假练习:[http://acm.hust.edu.cn/vjudge/contest/view.action?cid=70200 Special Round for Valentine's Day] I题 | ||
*原题链接:http://codeforces.com/problemset/problem/131/C | *原题链接:http://codeforces.com/problemset/problem/131/C | ||
| + | |||
==题意== | ==题意== | ||
有b男g女,选出k个人,使得其中有男>=4女>=1(每个人视作不同)。 | 有b男g女,选出k个人,使得其中有男>=4女>=1(每个人视作不同)。 | ||
| 题目链接 | 难度等级 | 完成状态 | 完成分数 | 最后编辑时间 | 失误原因(初次提交分数) |
|---|---|---|---|---|---|
| The World is a Theatre | ★☆☆☆☆ | 答案正确 | 100 | 2015-02-14 15:52:05 | 遗漏情况(4) |
有b男g女,选出k个人,使得其中有男>=4女>=1(每个人视作不同)。
高三的排列组合题呀……最简单的想法是排除法:
蠢得要死第一次一不小心把全是女生的情况漏了……
| 131C.cpp代码已折叠
展开折叠内容
|
|---|
#include<cstdio>
#include<iostream>
#include<cmath>
#include<iomanip>
#include<vector>
using namespace std;
#define si(n) scanf("%d",&n)
typedef unsigned long long ll;
#define ci const int&
ll c[100][100]={};
ll C(ci x,ci y)
{
if(!x||!y||x==y)return 1;
if(x<y)return 0;
if(c[x][y])return c[x][y];
return c[x][y]=C(x-1,y)+C(x-1,y-1);
}
int main()
{
int b,g,k;
scanf("%d%d%d",&b,&g,&k);
if(b>=4&&g>=1&&k>=5)
printf("%I64d",C(b+g,k)-C(b,k)-C(b,1)*C(g,k-1)-C(b,2)*C(g,k-2)-C(b,3)*C(g,k-3)-C(g,k));//fixed:漏了C(g,k)//
else
printf("0");
return 0;
}
|