HDU 4438 Hunters
Hunters
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1735 Accepted Submission(s):
1308
no preys can escape from them. However, they both think that its hunting skill
is better than the other. So they need a match.
In their match, the targets
are two animals, a tiger and a wolf. They both know that the tiger is living in
the south of the forest and the wolf is living in the north of the forest. They
decide that the one who kills the tiger scores X points and who kills the wolf
scores Y points. If the one who kills both tiger and wolf scores X+Y
points.
Before the match starts, Alice is in the east of the forest and Bob
is in the west of the forest. When the match starts, Alice and Bob will choose
one of the preys as targets. Because they haven't known the other's choice,
maybe they choose the same target. There will be two situations:
(1) If they
choose different targets, they both are sure of killing their respective
targets.
(2) If they choose the same target, the probability of Alice killing
the target is P, and the probability of Bob killing it is 1-P. Then they will
hunt for the other prey, also the probability of Alice killing it is P and the
probability of Bob killing it is 1-P.
But Alice knows about Bob. She knows
that the probability of Bob choosing tiger as his first target is Q, and the
probability of choosing wolf is 1-Q. So that Alice can decide her first target
to make her expected score as high as possible.
(1≤T≤10000), the number of test cases.
Then T test cases follow. Each test
case contains X, Y, P, Q in one line. X and Y are integers and 1≤X,
Y≤1000000000. P and Q are decimals and 0≤P, Q≤1, and there are at most two
digits after decimal point.
choose and the highest expected score she can get, in one line, separated by a
space. The expected score should be rounded to the fourth digit after decimal
point. It is guaranteed that Alice will have different expected score between
choosing tiger and wolf.
2 1 0.5 0.5
2 1 0 1
7 7 0.32 0.16
wolf 1.0000
tiger 6.5968
similar problems for you: 6263 6262 6261 6260 6259
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int t;
- cin >> t;
- while (t--)
- {
- int x, y;
- double p, q;
- cin >> x >> y >> p >> q;
- double s1, s2;
- s1 = p * q*p*(x + y) + ( - q)*x+(-p)*q*p*(x+y);
- s2 = p * p*( - q)*(x + y) + q * y+(-q)*p*(-p)*(x + y);
- if (s1 > s2)
- {
- printf("tiger %.4lf\n", s1);
- }
- else
- {
- printf("wolf %.4lf\n", s2);
- }
- }
- return ;
- }
HDU 4438 Hunters的更多相关文章
- HDU 4438 Hunters (数学,概率计算)
题意:猎人A和B要进行一场比赛.现在有两个猎物老虎和狼,打死老虎可以得X分,打死狼可以得Y分.现在有两种情况: (1)如果A与B的预定目标不同,那么他们都将猎到预定的目标. (2)如果A与B的预定目标 ...
- HDU 4438 Hunters 区域赛水题
本文转载于 http://blog.csdn.net/major_zhang/article/details/52197538 2012天津区域赛最水之题: 题意容易读懂,然后就是分情况求出A得分的数 ...
- poj 4438 Hunters
Hunters Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- hdu 4438 第37届ACM/ICPC 天津赛区现场赛H题
题意:Alice和Bob两个人去打猎,有两种(只)猎物老虎和狼: 杀死老虎得分x,狼得分y: 如果两个人都选择同样的猎物,则Alice得分的概率是p,则Bob得分的概率是(1-p): 但是Alice事 ...
- HDU 5115 Dire Wolf 区间dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5115 Dire Wolf Time Limit: 5000/5000 MS (Java/Others ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- Python学习札记(四十三) IO 3
参考:操作文件和目录 NOTE: 1.Python内置的os模块可以直接调用操作系统提供的接口函数: 2.os.name 打印操作系统的名称:如果是posix,说明系统是Linux.Unix或Mac ...
- SDN前瞻 传统网络架构的危机:危机“四”起
本文基于SDN导论的视频而成:SDN导论 在网络发展速度如此之快的今天,传统网络的架构充满了危机,主要有这四个问题(3+1). 1)传统网络的部署和管理 非常困难 2)分布式网络架构凸显瓶颈 3)流量 ...
- 使用SpringMVC自带的@Scheduled完成定时任务
首先在xml配置文件头中添加以下几行: xmlns:task="http://www.springframework.org/schema/task" http://www.s ...
- 【C#笔札】Tryparse的用法
这是参考读物的上得一个例子.自己仿照做的作业 private void button1_Click(object sender, EventArgs e) { int P_int_Number,i; ...
- Android 各API版本代码常量
Android开发中常常有版本比较这个功能,来做版本兼容或者,其他相关效果等 以下是Android 7.0版本下的源码: public static class VERSION_CODES { ...
- Invalid bound statement (not found)错误的可能原因
其他原因导致此问题解决参考: 1.检查xml文件所在package名称是否和Mapper interface所在的包名 <mapper namespace="me.tspace.pm. ...
- 使用Bus.js进行兄弟(非父子)组件通信
首先需要在任意地方添加一个bus.js: 在bus.js里面 写入下面信息 import Vue from 'vue' export default new Vue; 在需要通信的组件都引入Bus.j ...
- vim按下ctrl+s僵死
CTRL+S表示停止向终端停止输出 CTRL+Q恢复向终端输出流
- New Concept English Two 17 43
$课文41 你把那个叫帽子吗? 422. 'Do you call that a hat?' I said to my wife. “你把那个叫帽子吗?”我对妻子说. 423. 'You needn ...
- phalcon 设置cookie一直是httponly导致前端读取不到cookie的值
解决办法: 修改配置如果不好使,则暂时降低phalcon版本为3.1.2. 注意设置cookie的参数secure的值为false,否则js还是读取不到cookie