您的位置:首页 > 其它

hdu3910 Liang Guo Sha(期望)

2016-09-29 09:43 225 查看
思路:将Alice的期望写出来化简之后有E(x)=(pa*(a+b+2c)-b-c)pb-b*pa-c*pa+b 因为Alice与B是否出杀无关,即第一项pb那里的系数为0,所以可以推导出pa*(a+b+2c)-b-c=0,pa为Alice出杀的概率,解出来代会原式即可

#include<bits/stdc++.h>
using namespace std;

int main()
{
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
double pa = 1.0*(b+c)/(a+b+2*c);
printf("%.6lf\n",1.0*b-c*pa-b*pa);
}
}


Description

Maybe you know “San Guo Sha”, but I guess you didn’t hear the game: “Liang Guo Sha”! 

Let me introduce this game to you. Unlike “San Guo Sha” with its complicated rules, “Liang Guo Sha” is a simple game, it consists only four cards, two cards named “Sha”, and the other named “Shan”. 

Alice and Bob are good friends, and they’re playing “Liang Guo Sha” now. Everyone has two cards: a “Sha” and a “Shan”. Each round, everyone choose a card of his/her own, and show it together(Just show the selected card, do not
need to put it away). If both of them choose “Sha”, then Alice gets A points, and Bob loses A points; if both of them choose “Shan”, then Alice gets B points, and Bob
loses B points; otherwise, Bob gets C points, and Alice loses C points.   

Both Alice and Bob wants to get points as many as possible, they thought a optimal strategy: Calculating a percentage of choosing card “Sha” in order to ensure that even the opponent uses the optimal strategy, he/she can still get a
highest point exceptation. 

   

Here is the question, if both Alice and Bob use the optimal strategy to make their points higher, what is the expectation point which Alice can get in a round?

Input

Several test case, process to EOF. 

  Each test case has only a line, consists three positive integers: A, B, C respectively. 

  1 <= A, B, C <= 100000

Output

Each test case just need to output one line, the expectation point that Alice can get. Round to 6 decimal points.

Sample Input

2 10 4
3 3 3


Sample Output

0.200000
0.000000


Hint



In test case 1, both Alice and Bob calculated the best percentage of choosing “Sha”, and the their percentage are the same: 70%.
If Bob do not choose the best percentage, his strategy might be targetd.

For example, if Bob choose 100%, then Alice can change her percentage to 100%, Bob might lose many points. Bob is clever, so he won’t do that.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: