2016长城信息杯中国大学生程序设计竞赛中南邀请赛 xtu 1244 Gambling

https://i-blog.csdnimg.cn/blog_migrate/48aa95ec12d6891ba92de19d69ad7d91.png

In ICPCCamp, gambling is conducted as follow. A player will draw balls from an opaque bag containing a red balls, b green balls and c blue balls initially. Balls in the bag will be drawn in equal probability while drawn balls won't be put back into the bag. The player continues the process until he collects all a red balls, or all b green balls, or all c blue balls. He ends up with First Prize if he collects a red balls, or Second Prize if he collects b green balls, or Third Prize otherwise.

Bobo is going to take part in the above gambling. Therefore, it is very important for him to work out the probability of winning each prize.

Input

The input contains at most 40 sets. For each set:

Three integers a,b,c ( 1a,b,c103 ).

Output

For each set, three irreducible fractions pA,pB,pC denote the probability of winning First Price, Second Price, and Third Price, respectively.

Sample Input

1 1 1
1 2 3

Sample Output

1/3 1/3 1/3
7/12 4/15 3/20

只能说xtu死坑。。。 好些天写的了 死活不对 然后long long改成__int64就过了 我的天 omg wtf

设红a个 绿b个 黄c个

那么先取完红的前题下 最后一个取分两种 一种是黄 一种是绿 那么这两种概率相加不就是红了吗?

推一推公式 默认最后一个是绿 那么有((a+(b-1)+c)! /( a!*(b-1)!*c! ) )  /  ( (a+b+c)! /(a!*b!*c!)) 

化简得 b/(a+b+c)   然后在这之前 把黄球取完有 (a+c-1)!/(a!*(c-1)!) /(a+c)!/(a!*c!) 

化简得c/(a+c) 之两项成立 就是满足先取完红 再取完黄 再取完绿~~~

那么最后一个取绿=b/((a+b+c)   *  c/(a+c)           最后一个是黄=c/(a+b+c) *      b/(a+b)

两者相加  然后同理可以求出先取完绿  先取完黄   然后化简 就成了下面的这样

#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>
#include<cmath>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<string>
#include<string.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<ctime>
#include<bitset>
#define eps 1e-6
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define ll __int64
#define lson l,m,(rt<<1)
#define rson m+1,r,(rt<<1)|1
#define M 1000000007
using namespace std;
ll gcd(ll b,ll a)
{
    if(a%b==0)
        return b;
    return gcd(a%b,b);
}
int main()
{
    ll t1,t2,t3,x,y,z,u1,u2,u3,d1,d2,d3;
    while(scanf("%I64d %I64d %I64d",&x,&y,&z)==3)
    {
        ll sum=x+y+z;
        u1=y*z*(sum+x);
        d1=sum*(x+z)*(x+y);
 
        u2=x*z*(sum+y);
        d2=sum*(x+y)*(z+y);
 
        u3=x*y*(sum+z);
        d3=sum*(x+z)*(z+y);
        t1=gcd(u1,d1);
        t2=gcd(u2,d2);
        t3=gcd(u3,d3);
        printf("%I64d/%I64d %I64d/%I64d %I64d/%I64d\n",u1/t1,d1/t1,u2/t2,d2/t2,u3/t3,d3/t3);
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值