Hunters

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

Problem Description
Alice and Bob are the topmost hunters in the forest, so
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.
 
Input
The first line of input contains an integer T
(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.
 
Output
For each test case, output the target Alice should
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.
 
Sample Input
3
2 1 0.5 0.5
2 1 0 1
7 7 0.32 0.16
 
Sample Output
tiger 1.7500
wolf 1.0000
tiger 6.5968
 
Source
 
Recommend
zhoujiaqi2010   |   We have carefully selected several
similar problems for you:  6263 6262 6261 6260 6259 
 
分两种情况:
1.a选老虎 
      b选老虎 q
          a两个都打败的分数 :p*p    *q    *(x+y)
          a只打败了老虎,b打败了狼,a得到的分数:   p*(1-p)  *q   *x
          a只打败了狼,b打败了老虎,a得到的分数:    p*(1-p)  *q   *y
      b不选老虎 1-q
          a得到的分数  x
2.同理
 
 
 
 
 
 #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的更多相关文章

  1. HDU 4438 Hunters (数学,概率计算)

    题意:猎人A和B要进行一场比赛.现在有两个猎物老虎和狼,打死老虎可以得X分,打死狼可以得Y分.现在有两种情况: (1)如果A与B的预定目标不同,那么他们都将猎到预定的目标. (2)如果A与B的预定目标 ...

  2. HDU 4438 Hunters 区域赛水题

    本文转载于 http://blog.csdn.net/major_zhang/article/details/52197538 2012天津区域赛最水之题: 题意容易读懂,然后就是分情况求出A得分的数 ...

  3. poj 4438 Hunters

    Hunters Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  4. hdu 4438 第37届ACM/ICPC 天津赛区现场赛H题

    题意:Alice和Bob两个人去打猎,有两种(只)猎物老虎和狼: 杀死老虎得分x,狼得分y: 如果两个人都选择同样的猎物,则Alice得分的概率是p,则Bob得分的概率是(1-p): 但是Alice事 ...

  5. HDU 5115 Dire Wolf 区间dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5115 Dire Wolf Time Limit: 5000/5000 MS (Java/Others ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. SQL语句主要的分类

    SQL语言的命令通常分为四类1.数据定义语言(DDL) 创建.修改或删除数据库中各种对象,包括表.视图.索引等. 命令:CREATE TABLE , CREATE VIEW, CREATE INDEX ...

  2. codeforces 9 div2 C.Hexadecimal's Numbers 暴力打表

    C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...

  3. windows下利用批处理命令生成maven项目(java、javaWeb)

    觉得用IDE生成maven项目会卡住,很慢.就用cmd写了个cmd批处理命令来生成maven项目.效果如下 生成项目导入idea后结构如下 批处理命令代码如下 @echo off ::echo 请选择 ...

  4. ACM比赛学习指导(20180223)

    0.比赛介绍 (1)浙江省大学生程序设计比赛,3人一组,题目为英文 (2)ACM程序设计比赛 百度百科介绍 1.理论学习 (1)<挑战程序设计竞赛>,秋叶拓哉,巫泽俊 (2)<算法竞 ...

  5. devdocs

    https://devdocs.io/ docker run --rm -d --name devdocs -p 9292:9292 devdocs/devdocs

  6. UVALive-3268 Jamie's Contact Groups (最大流,网络流建模)

    题目大意:你的手机通讯录里有n个联系人,m个分组,其中,有的联系人在多个分组里.你的任务是在一些分组里删除一些联系人,使得每个联系人只在一个分组里并且使人数最多的那个分组人数最少.找出人数最多的那个分 ...

  7. Leetcode 50

    //1开始我只是按照原来快速幂的思想,当n <0 时,n变成-n,发现当n取-INTMAX时会发生越界的问题,然后在改快速幂代码的时候逐渐了解到快速幂的本质,其实位运算对快速幂来说速度加快不了多 ...

  8. ExtJs 6.0+快速入门,ext-bootstrap.js文件的分析,各版本API下载(一)

    ExtAPI 下载地址如下,包含各个版本 http://docs.sencha.com/misc/guides/offline_docs.html 1.使用工具HBuilder 2.java 版本 8 ...

  9. mysql基础运维

    1.创建用户并授权 一般新建数据库都需要新增一个用户,用于程序连接,这类用户只需要insert.update.delete.select权限. 新增一个用户,并授权如下: (1)grant selec ...

  10. Sizzle源码分析:一 设计思路

    一.前言 DOM选择器(Sizzle)是jQuery框架中非常重要的一部分,在H5还没有流行起来的时候,jQuery为我们提供了一个简洁,方便,高效的DOM操作模式,成为那个时代的经典.虽然现在Vue ...