Liang Guo Sha

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 527    Accepted Submission(s): 367

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?

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.

Source
2011 Multi-University Training Contest 8 - Host by HUST

题目大意:

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.

给定A B C的值,求Alice得分的数学期望,已知Alice的数学期望与Bob无关。

解题思路:

假设Alice出杀的概率为pa,Bob出杀的概率为pb

则Alice得分的数学期望EX(Alice)=a*pa*pb+b*(1-pa)*(1-pb)-c*pa*(1-pb)-c*(1-pa)*pb;

整理得 EX(Alice)=pb*(a*pa+b*pa-b-c+2*c*pa)+b-b*pa-c*pa;

既然Alice的数学期望与Bob无关,那么pb的系数为0,则(a*pa+b*pa-b-c+2*c*pa)=0,

解得,pa=(b+c)/(a+2*c+b);

带入原方程求解得到答案

代码:

#include <iostream>
#include <cstdio>
using namespace std;int main(){double a,b,c;while(cin>>a>>b>>c){double pa=(b+c)/(a+2*c+b);double ans=b-b*pa-c*pa;printf("%.6lf\n",ans);}return 0;
}

HDU 3910 Liang Guo Sha相关推荐

  1. hdu3910 Liang Guo Sha(期望)

    思路:将Alice的期望写出来化简之后有E(x)=(pa*(a+b+2c)-b-c)pb-b*pa-c*pa+b 因为Alice与B是否出杀无关,即第一项pb那里的系数为0,所以可以推导出pa*(a+ ...

  2. 【C#公共帮助类】10年代码,最全的系统帮助类

    这个帮助类主要包含:对象转换处理 .分割字符串.截取字符串.删除最后结尾的一个逗号. 删除最后结尾的指定字符后的字符. 生成指定长度的字符串. 生成日期随机码. 生成随机字母或数.字 截取字符长度. ...

  3. 汉字转拼音,一二级词库,不支持多音字

    GB2312标准共收录6763个汉字,其中一级汉字3755个,二级汉字3008个. 分区表示  GB 2312中对所收汉字进行了"分区"处理,每区含有94个汉字/符号.这种表示方式 ...

  4. 今天收到一封MAIL,是转发了N次转发过来的,标题就叫 FW 听说是真有此事 ,内容如下(我是不信的,至于你怎么

    今天收到一封MAIL,是转发了N次转发过来的,标题就叫"FW: ^_^听说是真有此事",内容如下(我是不信的,至于你怎么看,就看你的行动了.不过,真的有趣,让我想起了以前的关于将I ...

  5. 完整的系统帮助类Utils

    //来源:http://www.cnblogs.com/yuangang/p/5477324.html using System; using System.Collections.Generic; ...

  6. C#实现汉字转全拼与简拼

    功能描述:         1.将字符串转换为全拼表示         2.将字符串转换为全拼表示,汉字拼音之间空格分隔         3.将字符串转换为全拼表示,汉字拼音之间的分隔符可以指定    ...

  7. 汉字转全拼,简拼组件

    这几天研究了一下如何获取汉字拼音.在网上找了一些资料.也了解了一些有关汉字编码的新概念(对本人来讲的新概念).         比如:机内码,ASCII码等         在搜索的过程中,发现几乎所 ...

  8. C#下汉字转换成拼音

    因为一个开发需求需要把汉字转换成拼音,没想到还真的可以! 找了一个类,是别人整理的,默认情况下第一个字母是大写的.我这边需要都是小写的,可以按照自己情况进行实际的需求进行修改,比如有些时候只要首字母就 ...

  9. GB2312-80 所有汉字排序,拼音

    须知:所有这些汉字都是GB2312-80标准中说明的汉字. 下面的这些规则不一定适用其它标准中的汉字范围. // 各声母的汉字界限. 这是经过将GB2312-80标准中的所有汉字排序后,获取拼音后提取 ...

最新文章

  1. redis 在 php 中的应用(事务 [ Transaction ] 篇)
  2. All about OpenGL ES 2.x – (part 2/3)(转载)
  3. VC++ 文件和应用程序关联,默认图标不显示问题
  4. 白话Elasticsearch42-深入聚合数据分析之案例实战__bucket filter:统计牌品最近一个月的平均价格(Filter Aggregation)
  5. opencl获取gpu信息_如果在尝试获取OpenCL gpu设备类型时,Char *语句出现问题
  6. 抚摸那条船——彭晓东
  7. servlet面试常考 (转载)
  8. 逆反过程的学习会如何
  9. [Selenium] 操作新弹出窗口之验证标题和内容
  10. C语言 · 9-1九宫格
  11. 深入理解java虚拟机章节_深入理解java虚拟机-第六章
  12. paip. 解决java程序不能自动退出
  13. 如何下载使用期刊 LateX 模板
  14. 行为识别论文笔记|ARTNet|Appearance-and-Relation Networks for Video Classification
  15. 无人机——电池、电机、螺旋桨搭配
  16. 张小龙回应一切!2019微信公开课一人撑到半夜,4小时演讲3万字实录
  17. 图神经网络学习过程心得总结
  18. 腾讯云服务器备案全流程详细内容记录40天备案的血与泪
  19. 热加工作业考研题目答案分享——Joining processes 4
  20. 机器语言、汇编语言和高级语言的区别和互相间的关系

热门文章

  1. 塞班s60v2和s60v3所有的诺基亚软件sisx大全
  2. Linux命令:使用dig命令解析域名
  3. RAID10 (146G*8) vs EMC VNX 5300 (8G Fibre Channel)
  4. 机器学习实战三: 预测汽车油耗效率 MPG
  5. CSC Matrix
  6. HAXM无法安装的原因(ARM处理器的福音)
  7. Android app 性能测试以及专项测试
  8. 操作系统:Win11首个预览版来了!附升级方法
  9. 概率论与统计推断(四) ------ 统计推断
  10. android蓝牙双通道意义,BCM43598双通道SDIO接口双频11ac级蓝牙WiFi