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 ...
随机推荐
- Django-ORM查询api
models.py示例 class Book(models.Model): nid=models.AutoField(primary_key=True) title=models.CharField( ...
- IIS 7.5 配置 php 5.4.22 链接 sql 2008(用PDO链接数据库)
最近在接触PHP这块,关于在wndows系统下的php配置,虽然网上已经很多文章,但有时候有些配置找起也麻烦,所以分享给大家. 一.php 5.4.22 下载地址 http://windows.php ...
- Codeforces Round #381 (Div. 2) D. Alyona and a tree dfs序+树状数组
D. Alyona and a tree time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- hdu 5683 zxa and xor 暴力
zxa and xor Time Limit: 16000/8000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Pro ...
- 上海仪电Azure Stack技术深入浅出系列1:谈Azure Stack在私有云/混合云生态中的定位
2.2 Azure Stack Azure Stack到2017年7月才提供GA版本,但目前还是可以通过技术预览版了解该技术.Azure Stack本质上是核心Azure服务的一个私有实例. Micr ...
- Flex 布局的各属性取值解释
Flex布局是一种弹性布局.布局样式比较灵活,大多数情况下可以替代float,而且不会脱离文档里流. Flex中定义了两个轴线,一个主轴一个副轴,这个概念你可以想想屏幕坐标系(X轴向右,Y轴向下),F ...
- 前端引用公共html模块方案
最近临时一个负责公司官网的妹纸请假,于是临时接手了下官网的项目,官网都是静态页面,算是很简单的,但发现页面挺多,而每个页面总有部分是和其他页面一模一样的,比如页头.页尾等,这样就导致一个地方的修改要在 ...
- ng-disabled 指令
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- 个人知识管理系统Version1.0开发记录(09)
MyBatis初试 MyBatis 是支持普通 SQL查询,存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的JDBC代码和参数的手工设置以及结果集的检索. 运用Mybatis框 ...
- 牛客网——G大水题
链接:https://www.nowcoder.net/acm/contest/75/G来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语言65536K ...