gym 101124 Problem E. Dance Party(概率)

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);
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值