poj 4438 Hunters
Hunters
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1588 Accepted Submission(s):
1194
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
#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
using namespace std;
const int N_MAX = +;
double P, Q,X,Y;
int main() {
int T;
scanf("%d",&T);
while (T--) {
scanf("%lf%lf%lf%lf", &X, &Y, &P, &Q);
double ext_1 = ( - Q)*X + Q*(X*P + Y*P);
double ext_2 = Q*Y + ( - Q)*(Y*P + X*P);
if (ext_1 > ext_2) {
printf("tiger %.4lf\n", ext_1);
}
else
printf("wolf %.4lf\n",ext_2);
}
return ;
}
poj 4438 Hunters的更多相关文章
- HDU 4438 Hunters
Hunters Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- 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 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
随机推荐
- Python基础篇 -- 集合
set集合 set 中的元素是不重复的,无序的 里面的元素必须是可hash的,(int str tuple bool) set 就是dict 类型的数据,但是不保存value 只保存 key set集 ...
- Java中List集合排序的方法 比较器的使用 根据学生对象数学 语文 英语成绩总和进行sort排序
package com.swift; import java.util.ArrayList; import java.util.Collections; import java.util.Compar ...
- 前端开发面试题之JavaScript(转自公众号)(1)
js基本数据类型:Undefine Number Null Boolean String; js内置对象:数据封装类对象:object.Array.Boolean.String: 其他:Functio ...
- NOIP2016——一个逗号引发的血案
今年江西省报名人数一下子增起来了 隔壁中学来了80+人(虽然都是来给我们垫底的...临时被老师抓来上战场 总之我们赛区参赛人数总算多起来了(起码没再减50%...连续4年减50%真不是随便说说的... ...
- 【kmp】bzoj3620: 似乎在梦中见过的样子
考察kmp理解题 Description “Madoka,不要相信 QB!”伴随着 Homura 的失望地喊叫,Madoka 与 QB 签订了契约. 这是 Modoka 的一个噩梦,也同时是上个轮回中 ...
- React和Vue组件间数据传递demo
一.React (一)父组件向子组件传数据 简单的向下传递参数 /* Parent */ class App extends Component { render() { return ( <d ...
- 代理工具--fiddle
正则匹配 1)前缀为“EXACT:”表示完全匹配:只有match=rules时,才匹配 2)无前缀表示基本搜索,表示搜索到字符串就匹配:只要match中包含了rules的字符串,即可 3)前缀为“NO ...
- 15.Yii2.0框架where单表查询
目录 新建控制器 HomeController.php 新建model article.php 新建控制器 HomeController.php D:\xampp\htdocs\yii\control ...
- python列表中的深浅copy
列表中的赋值和平常的赋值是不一样的,看下面的代码: In [1]: a = 1 In [2]: b = a In [3]: a Out[3]: 1 In [4]: b Out[4]: 1 In [5] ...
- cpu位图
SMP处理器中要用到cpu位图,用来维护系统内CPU的状态信息,具有代表性的有: cpu_possible_map.cpu_online_map.cpu_present_map. static DEC ...