gym 101124 Problem E. Dance Party(概率)
2017-03-02 23:13
316 查看
Problem E. Dance Party
Time limit: 0.5 secondsMemory limit: 256 megabytes
Dance parties, whether formal balls or less formal events, usuallyhave dress codes for the guests. The code may be more or lessstrict. In case of a formal ball, the style of music and dances,such as
Classicism, Empire, Rococo, Romantism, Biedermeier,Modernism, also determines the dress code. In less formal parties,any simple unusual idea can be good fun.
For one party, it was decided to assign a color for each guest. Thecolors would be drawn in advance and everyone would have tocome dressed in the assigned color. Each color would be assignedto two persons
and guests with matching colors would form pairsfor the first dance. Everything looked fine until it was found thatthe color lists for ladies and gentelmen were not separate; instead,everyone drew their color from one big list. Thus, it was possible,that a
pair will be formed either by a gentelman and a lady, ortwo ladies, or even two gentelmen. The organizer of the eventresponded to the concerns with “the probability of a male-malepair is extremely low”, but Pat still suspects that the probabilityof getting
at least one such pair is too high. To compute theactual probability, he asked the organizer to provide the numberof colors and the numbers of ladies and gentelmen expected toparticipate in the dance. Having gotten these, he now wondershow to actually compute
the probability.
Input
The only line of input contains three integers
C,
M and
F(1
≤ C,M,F
≤ 109;
M +F
≤ 2C),
the numbers of colors, gentel-men, and ladies, respectively.
博客链接
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const int inf=0x3fffffff;
const ll mod=1000000007;
const int maxn=5e5+100;
int main()
{
int c,m,f;
scanf("%d%d%d",&c,&m,&f);
double ans=1;
rep(i,1,m)
{
ans*=(1-1.0*i/(2*c-i));
if(ans<1e-10) break;
}
printf("%.10f\n",1-ans);
}
Time limit: 0.5 secondsMemory limit: 256 megabytes
Dance parties, whether formal balls or less formal events, usuallyhave dress codes for the guests. The code may be more or lessstrict. In case of a formal ball, the style of music and dances,such as
Classicism, Empire, Rococo, Romantism, Biedermeier,Modernism, also determines the dress code. In less formal parties,any simple unusual idea can be good fun.
For one party, it was decided to assign a color for each guest. Thecolors would be drawn in advance and everyone would have tocome dressed in the assigned color. Each color would be assignedto two persons
and guests with matching colors would form pairsfor the first dance. Everything looked fine until it was found thatthe color lists for ladies and gentelmen were not separate; instead,everyone drew their color from one big list. Thus, it was possible,that a
pair will be formed either by a gentelman and a lady, ortwo ladies, or even two gentelmen. The organizer of the eventresponded to the concerns with “the probability of a male-malepair is extremely low”, but Pat still suspects that the probabilityof getting
at least one such pair is too high. To compute theactual probability, he asked the organizer to provide the numberof colors and the numbers of ladies and gentelmen expected toparticipate in the dance. Having gotten these, he now wondershow to actually compute
the probability.
Input
The only line of input contains three integers
C,
M and
F(1
≤ C,M,F
≤ 109;
M +F
≤ 2C),
the numbers of colors, gentel-men, and ladies, respectively.
博客链接
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define fi first
#define se second
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const int inf=0x3fffffff;
const ll mod=1000000007;
const int maxn=5e5+100;
int main()
{
int c,m,f;
scanf("%d%d%d",&c,&m,&f);
double ans=1;
rep(i,1,m)
{
ans*=(1-1.0*i/(2*c-i));
if(ans<1e-10) break;
}
printf("%.10f\n",1-ans);
}
相关文章推荐
- 【 Gym - 101124E 】Dance Party (数学)
- “ 鸡尾酒会问题”(cocktail party problem)
- fzu 2278 YYS [第八届福建省大学生程序设计竞赛 Problem G] [概率]
- 【Gym 100685J】Just Another Disney Problem(交互/排序)
- Gym 100646 Problem E: Su-Su-Sudoku 水题
- ABBYY Cup 2.0 - Easy, problem: (C1) Party 并查集水题
- Gym 100646 Problem C: LCR 模拟题
- 【BZOJ 2318】 2318: Spoj4060 game with probability Problem(概率DP)
- 【递推】【概率】Gym - 100814A - Arcade Game
- hust 1024 dance party
- [CF442B] Andrey and Problem (概率dp)
- 【概率dp】【数学期望】Gym - 101190F - Foreign Postcards
- GYM 100090 L.Hard Problem(水~)
- HDU Problem 5395 Gym Class 【拓扑排序+优先队列】
- Codeforces Round #253 Div2 D.Andrey and Problem 概率+贪心
- Codeforces Beta Round #16 (Div. 2 Only), problem: (E) Fish 概率DP
- [BZOJ2318][SPOJ4060]Game with probability Problem 概率DP
- UVALive 7962|Gym 101201K|Tournament Wins|概率期望|组合数求对数
- HUST1024 dance party(最大流)
- GYM 101550 F.Fleecing the Raffle(概率)