您的位置:首页 > 其它

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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: