[hdu4438]Hunters
来源:互联网 发布:尤尼克斯和李宁 知乎 编辑:程序博客网 时间:2024/05/16 15:58
Hunters
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 989 Accepted Submission(s): 756
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.
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.
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
32 1 0.5 0.52 1 0 17 7 0.32 0.16
Sample Output
tiger 1.7500wolf 1.0000tiger 6.5968
Source
2012 Asia Tianjin Regional Contest
天津现场赛题目
画一下样例能看出来公式 具体见代码吧
天津现场赛题目
画一下样例能看出来公式 具体见代码吧
#include<iostream>#include<cstdio>using namespace std;int main(){ int T; double X,Y,P,Q; scanf("%d",&T); for (int i=1;i<=T;i++) { scanf("%lf%lf%lf%lf",&X,&Y,&P,&Q); double tiger,wolf; tiger=X*(1-Q)+(X*P+Y*P)*Q; wolf=Y*Q+(Y*P+X*P)*(1-Q); if (tiger>wolf) printf("tiger "); else printf("wolf "); printf("%.4f\n",max(tiger,wolf)); } return 0;}
0 0
- hdu4438 - Hunters
- hdu4438 Hunters
- [hdu4438]Hunters
- [HDU4438][TJ08H]Hunters
- HDU4438
- hdu44438 Hunters
- hdu 4438 Hunters
- A - Hunters题解
- hdu 4438 Hunters
- HDU 4438 Hunters(模拟)
- HDU-#4438 Hunters
- HDU-4438-Hunters
- HDU 4438 Hunters
- HDU 4438 Hunters 简单概率
- HDU-4438 Hunters 期望 水
- HDU—— 4438 Hunters
- hdu 4438 Hunters(数学期望)
- hdu 4438 Hunters【数学水题】
- 将本地jar包手动拷贝到Maven库中,在其他电脑上用Maven打包时出错
- 百度社会化用到jsonkit的bug
- Hive中的LEFT SEMI JOIN<转>
- [Visual Studio & Xamarin] 开发架构(四)-跨平台的MVVMCross与portable class library–Windows Phone 8
- 面向对象的CSS(OOCSS)
- [hdu4438]Hunters
- 网络变压器在以太网中的作用
- 使用Visual Studio 创建新的Web Part项目
- django--中文乱码问题
- 习近平领导风格鲜明 网民称展现独特“主席范儿”
- banana pi 香蕉派是树莓派的"克隆"吗
- MFC 获取自己模块路径
- gen already exists but is not a source folder. Convert to a source folder or rename it.
- cocos2d-x-3.1 事件分发机制 (coco2d-x 学习笔记七)