HDU 3910 Liang Guo Sha
来源:互联网 发布:java类库有哪些 编辑:程序博客网 时间:2024/04/29 13:35
Problem 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?
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
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 43 3 3
Sample Output
0.2000000.000000HintIn 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.
参考了题解 http://blog.csdn.net/ivan_zjj/article/details/7927970
题目中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.
很重要
代码:
#include<stdio.h>int main(){ int A,B,C; while(scanf("%d%d%d",&A,&B,&C)!=EOF) { double x=(double)(B+C)/(A+B+C*2); printf("%.6lf\n",(1-x)*B-x*C); } return 0;}
- hdu 3910 Liang Guo Sha
- hdu 3910 Liang Guo Sha
- HDU 3910 Liang Guo Sha
- Hdu 3910 Liang Guo Sha
- HDU 3910 Liang Guo Sha
- hdoj-3910-Liang Guo Sha
- HDU_3910 Liang Guo Sha
- hdu_3910 Liang Guo Sha(概率论)
- hdu3910 Liang Guo Sha(期望)
- San Guo Sha
- liang
- hdu 4739 Zhuge Liang's Mines
- HDU 4739 Zhuge Liang's Mines
- HDU 4739 Zhuge Liang's Mines
- HDU 4739 Zhuge Liang's Mines
- hdu 4739 Zhuge Liang's Mines
- HDU 4739 Zhuge Liang's Mines
- hdu 4772 Zhuge Liang's Password
- 使用循环坐标下降(CCD)算法解算反向运动学(IK)
- JVM Knowledges-垃圾回收算法
- 拿什么来拯救你,电视!
- 9、tcp协议
- 流媒体开发之--HLS--M3U8解析(1)
- HDU 3910 Liang Guo Sha
- Android学习篇章23-SQLite数据库操作:SQLiteOpenHelper-单例模式
- 流媒体开发之--HLS--M3U8解析(2): HLS草案
- 直接拿来用!10款实用Android UI工具
- 10、tcp连接和建立
- 11.其他对象【System】【Runtime】【Math】【Date】【Calendar】
- (+)第112天的交易(2013-11-1)(+50)(70.82)
- Android短信编解码方式
- linux c/c++ 编程之-----makefile 初探