Hunters

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

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
题意:两个猎人比赛打猎,现在猎物有老虎和狼,猎杀老虎有X分,猎杀狼有Y分,并且其中一个猎人Alice知道同伴选择猎杀老虎的概率Q,猎杀狼的概率为(1-Q),并且如果两个人分别独自猎杀狼或者老虎,都能百分百将猎物猎杀,但如果他们选择
猎杀同一猎物,不管猎杀谁,Alice都有P的概率率先猎杀猎物,而其同伴则有(1-P)的概率猎杀猎物,求Alice的期望分数,并输出最高的期望分数(选狼还是选老虎)。
思路:概率问题,程序就是计算得到的期望公式就好了,没什么难度。期望公式
Alice选老虎的E(score)=( - Q)*X + Q*(X*P + Y*P) 
Alice选狼的   E(score)=Q*Y + ( - Q)*(Y*P + X*P)
AC代码:
#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的更多相关文章

  1. HDU 4438 Hunters

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

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

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

  3. HDU 4438 Hunters 区域赛水题

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

  4. POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理

    Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798 ...

  5. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  6. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  7. POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Descr ...

  8. POJ 3254. Corn Fields 状态压缩DP (入门级)

    Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Descr ...

  9. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

随机推荐

  1. 禅与 Objective-C 编程艺术(Zen and the Art of the Objective-C Craftsmanship)

    英文版Zen and the Art of the Objective-C Craftsmanshiphttps://github.com/objc-zen/objc-zen-book 中文版禅与 O ...

  2. ReactiveCocoa概念解释篇

    1.ReactiveCocoa简介 ReactiveCocoa(简称为RAC),是由Github开源的一个应用于iOS和OS开发的新框架,Cocoa是苹果整套框架的简称,因此很多苹果框架喜欢以Coco ...

  3. day3- python 注册

    # .先把文件内容的账号密码放到list/字典 f = open('users') result = f.read() f.close() user_list = result.split() # u ...

  4. 地理位置编码geohash学习笔记

    1.geohash及其性质 一种空间索引技术. (1)将二维的经纬度位置数据转换为一维的字符串(基本上hash族的算法都是这样): 其优点在于hash编码后的字符串,可以方便查找和索引,从而减少相似计 ...

  5. 前端MVVM模式及其在Vue和React中的体现

    MVVM相关概念 Mvvm 前端数据流框架精讲 1) MVVM典型特点是有四个概念:Model.View.ViewModel.绑定器.MVVM可以是单向绑定也可以是双向绑定甚至是不绑定 2) 绑定器: ...

  6. PHP将unicode转utf8最简法

    最近开发时遇到Unicode编码问题,找了半天才知道PHP并没有Unicode转码函数,终于发现用一行PHP代码解决的方案: $str = '{"success":true,&qu ...

  7. mybatis枚举类型处理器

    1. 定义枚举值的接口 public abstract interface ValuedEnum { int getValue(); } 所有要被mybatis处理的枚举类继承该接口 2. 定义枚举类 ...

  8. mysql 编程

    一.存储函数 相当于php或者js中有返回值的函数 --完成一定“计算”后返回单个的数据值 定义: create function 函数名(parameter p1 value_type, param ...

  9. pyecharts用法,本人亲测,陆续更新

    主题 除了默认的白色底色和dark之外,还支持安装扩展包 pip install echarts-themes-pypkg echarts-themes-pypkg 提供了 vintage, maca ...

  10. github FATAL:unable to access 'https://github.com/...: Failed to connect to github.com:443; No error

    今天整理github,初次使用,很多都不懂,所以遇到了克隆失败的问题,研究了大半天,后来..... 打开Git Bash,克隆已有工程到本地: $ git clone https://github.c ...