Hunters

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 25   Accepted Submission(s) : 14
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
2012 Asia Tianjin Regional Contest

 #include <stdio.h>
#include <stdlib.h> int main()
{
int T,X,Y;
double Q,P,tiger,wolf;
scanf("%d",&T);
while(T--)
{
getchar();
scanf("%d%d%lf%lf",&X,&Y,&P,&Q);
tiger=(-Q)*X+Q*P*(X+Y);
wolf=Q*Y+(-Q)*P*(X+Y);
if(tiger>wolf)
printf("tiger %.4lf\n",tiger);
else
printf("wolf %.4lf\n",wolf);
}
return ; }

Hunters的更多相关文章

  1. Code Hunters: Hello, world!

    大家好!我们是来自MSRA联合培养班的Code Hunters小组,在未来三个月时间里我们将与殷秋丰老师一起学习高级软件工程这门课. 我们小组共有五名分别来自享誉海内外的中国科学技术大学和北京航空航天 ...

  2. HDU 4438 Hunters

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

  3. poj 4438 Hunters

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

  4. 《月之猎人 (Moon Hunters)》主角设计

    原文链接 游戏开发人员,你们好! 我是 Kitfox Games 工作室的总监 Tanya,我们的工作室位于加拿大的蒙特利尔,拥有六名员工. 我们 3 月份发布了<月之猎人>游戏的桌面版, ...

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

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

  6. 5 THINGS TOP BUG BOUNTY HUNTERS DO DIFFERENTLY

    出处:https://www.hackerone.com/blog/5-things-top-bug-bounty-hunters-do-differently 本周,我们有幸收容了50名比利时科技学 ...

  7. HDU 4438 Hunters 区域赛水题

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

  8. 【转载学习前辈的经验】-- Mistakes I made (as a developer) 我(作为一名开发者)所犯过的错误

    我 2006 年开始工作,至今已经 10 年.10 年是个里程碑,我开始回顾自己曾经犯过的错误,以及我希望从同行那里得到什么类型的忠告.一切都在快速改变,10 年了,我不能确定这些秘诀是否还有用. 不 ...

  9. 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)

    第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1 ...

随机推荐

  1. Java. Warning – Build path specifies execution environment J2SE-1.5

    Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace th ...

  2. 【转载】javadoc学习笔记和可能的注意细节

    转载自:http://www.cnblogs.com/xt0810/p/3630996.html [前面的话] 这次开发项目使用jenkins做持续集成,PMD检查代码,Junit做单元测试,还会自动 ...

  3. js跨域请求获得数据

    很多时候我们想访问其它站点下的数据怎么办? 由于javascript语言安全限制即同源策略造成的. 在使用ajax请求访问其他服务器的数据,此时客户端会出现跨域问题. 在js中,我们直接用XMLHtt ...

  4. $(#form :input)与$(#form input)的区别

    相信大家都很奇怪这两者的区别 我从两个方面简单介绍下 1. $("form :input") 返回form中的所有表单对象,包括textarea.select.button等    ...

  5. Java AOP - Aspectj

    1. 序 Aspect Oriented Programming (AOP)是近来一个比较热门的话题. AspectJ是AOP的Java语言的实现,获得了Java程序员的广泛关注. 关于AspectJ ...

  6. Javaweb 第5天 mysql 数据库课程

    MySQL数据库课程 两日大纲 ● 数据库的概念.MySQL快速入门.SQL语言简介 ● 数据库操作.表操作.数据记录操作.数据类型和约束 ● 查询 ● 多表关系.多表连接查询 ● 视图 ● 数据备份 ...

  7. document.body 和 document.documentElement 的区别

    document.body 和 document.documentElement 的区别 : www.cnblogs.com/scy251147/archive/2011/04/10/2011420. ...

  8. 戏说HTML5(转)

    如果有非技术人员问你,HTML5是什么,你会怎么回答? 新的HTML规范... 给浏览器提供了牛逼能力,干以前不能干的事...(确切地说应该是给浏览器规定了许多新的接口标准,要求浏览器实现牛逼的功能. ...

  9. mysql创建用户、授权[转]

    一, 创建用户: 命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 说明:username - 你将创建的用户名, host - 指 ...

  10. 7、Web应用程序中的安全向量 -- 使用Retail部署配置

    该方法不需要胡乱地编辑各个配置设置,而是利用了ASP.NET特性:Retail部署配置. 部署配置是服务器的machine.config文件(在%windir%\Microsoft.NET\Frame ...