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.
The input contains at most40sets. For each set:
Three integersa,b,c(1≤a,b,c≤103).
For each set, three irreducible fractionspA,pB,pCdenote the probability of winning First Price, Second Price, and Third Price, respectively.
1 1 1 1 2 3
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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include