关闭

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

1209人阅读 评论(0) 收藏 举报
分类:

http://www.dengwenhuo.cn/?id=199

In ICPCCamp, gambling is conducted as follow. A player will draw balls from an opaque bag containingared balls,bgreen balls andcblue 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 allared balls, or allbgreen balls, or allcblue balls. He ends up with First Prize if he collectsared balls, or Second Prize if he collectsbgreen 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 most40sets. For each set:

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

Output

For each set, three irreducible fractionspA,pB,pCdenote 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

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:57344次
    • 积分:2160
    • 等级:
    • 排名:第19700名
    • 原创:160篇
    • 转载:30篇
    • 译文:0篇
    • 评论:1条
    文章分类
    最新评论