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

来源:互联网 发布:移动互联网数据 编辑:程序博客网 时间:2024/04/28 18:23

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 11 2 3

Sample Output

1/3 1/3 1/37/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 1000000007using 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
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 把线稿画在背景里了怎么办 蜗牛在家里跑了怎么办 小孩总是跟大人犟嘴怎么办 鹅当宠物养拉屎怎么办 金毛肚子胀很大怎么办 被小白兔咬了怎么办 仓鼠养在家里有味怎么办 被宠物仓鼠咬了怎么办 2个月小狗拉稀怎么办 家有很多小飞虫怎么办 孩子不和父母微信交流怎么办 我孩子和我顶嘴怎么办 我属龙孩子属狗怎么办 宝宝呛奶怎么办伴呼噜 离婚了欠的债务怎么办 小鸟生长发育过程壳破了怎么办 经常嗓子发炎抵抗力低下怎么办 生完孩子出虚汗怎么办 3岁宝宝抵抗力差怎么办 5岁宝宝免疫力低怎么办 狗狗后腿o型怎么办 狗狗前腿内八字怎么办 小猫腿摔瘸了怎么办会好吗 小狗的腿断了怎么办 狗后腿摔瘸了怎么办 狗狗脖子挠破了怎么办 狗狗脖子挠破化脓怎么办 狗狗大腿骨折了怎么办啊 狗狗洗澡后拉稀怎么办 狗狗好像生病了怎么办 奶狗前腿断了怎么办 狗摔了一下瘸了怎么办 小狗腿突然瘸了怎么办 狗腿突然瘸了怎么办 狗腿受伤了肿了怎么办 狗狗缺钙腿变形怎么办 小狗腿摔骨折了怎么办 狗狗脚掌被压了怎么办 狗狗的脚骨折了怎么办 给猫灌药水呛到怎么办 吃佐匹克隆白天工作量降低怎么办?