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

1366人阅读 评论(0)

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

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

个人资料
等级：
访问量： 6万+
积分： 2265
排名： 1万+
最新评论