Juan have N red marbles, M blue marbles, and K bottles. He will put a certain number of marbles on each of the K bottles such that no bottle remains empty and every marble is inside a bottle.
Andres is a Santa Fe fan, so he will pick one bottle at random with an uniform distribution, then he will pick a marble inside of it at random with an uniform distribution, with the hope is a red marble. As Juan is a Millonarios fan, he wants to distribute the marbles in the bottles such that the probability of Andres picking a blue marble is maximized. Juan has a busy life, therefore he needs your help to determine the best arrangement for the marbles and the probability of Andres getting a blue marble.
Input
The input consist of three integers separated by spaces, N M and K (1 ≤ N, M, K ≤ 109) - the number of red marbles, blue marbles and bottles respectively.
Output
Print the probability of Bob getting a blue marble such that the marble arrangement is optimal. Your answer will be considered correct, if its absolute or relative error does not exceed 10 - 6.
Example
Input
50 50 2
Output
0.747474747
推荐个地方好理解一下题;
题意:
关于'我他妈的爱科学小组'的毕业生再次辩论这个。请显示您的所有工作:
你有50个红色大理石,50个蓝色大理石和2个罐子。
你的朋友会随机从其中一个罐子里拿出一块大理石。你必须将所有100个大理石放在两个罐子中,但你必须使用所有100个大理石和两个罐子。你怎么能最大化你的朋友画红色大理石的机会?
解答:问题含糊不清,因此至少有三种不同的解释方式:
1.你的朋友将随意均匀地选择一个罐子,然后随机均匀地从那个罐子中选择一个大理石。
我们希望两个罐子中红色大理石的平均百分比最大化。如果一个罐子里的红色大于蓝色大理石,那么另一个罐子里的蓝色大理石比红色大理石更多。将这些罐子分别称为“红罐子”和“蓝罐子”[1]。在所有的安排中,你从红色罐子里画出红色大理石的最大可能性是100%,这是在红色罐子里没有蓝色大理石的情况下实现的。在所有的安排中,你从蓝色罐子里画出红色大理石的最大可能性是49/99,在那个罐子里有49个红色大理石和50个蓝色大理石的情况下实现。
由于在一个罐子里放置一个红色大理石而在另一个罐子里放置所有其他罐子,最大化了我们试图最大化的概率,这是最佳的。 [2]
2.你的朋友将检查两个罐子,选择一个罐子,然后从那个罐子里随机均匀地取一块大理石,希望得到一块蓝色大理石。(注意理解这种情况:你希望朋友取得红球的概率最大,然而朋友却希望取得蓝球,两个人的目标并不相同,真是坑朋友啊!!!)
在这种情况下,如果一个罐子的红色大理石比蓝色大理石更多,那么另一个罐子的红色大理石比红色大理石更多,所以你想在每个罐子里放入相同数量的红色和蓝色大理石。
你的朋友会检查两个罐子,选择一个罐子,然后从那个罐子里随意拿一块大理石,希望得到一个红色的大理石。
这是最简单的情况:只需安排它,以便其中一个罐子里面没有任何蓝色大理石。
[1]如果你想要完全正式,让我们说如果两个罐子都有相同数量的红色和蓝色大理石,那么我们任意分配标签“红色罐子”和“蓝色罐子”。
[2]这当然与Anonymous的答案相同,这是在我打字时发布的。 Michael Hochster的回答和Breno Sakaguti的回答得出了相同的结论,但我更喜欢这个版本的论点。当然,我只是欣赏它,因为我理解他们的蛮力和更普遍的问题解决方案;对于没有这样做的人来说,这可能不是最佳起点。一般来说,在这样的问题中,你将无法同时最大化这两个概率,所以你必须做更像其他解决方案的事情。
代码:
#include <iostream>
#include <bits/stdc++.h>
#include <stdio.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main()
{
int a,b,c;
cin >> a >> b >> c;
if(b<=c-1){
printf("%.9lf",(b)*1.000000000/c*1.000000000);
}
else{
double sum=((c-1)*1.00000000/c*1.00000000)+((b-c+1)*1.000000000/(b-c+1+a)*1.000000000/(c)*1.000000000);
printf("%.9lf",sum);
}
return 0;
}