首页 技术 正文
技术 2022年11月12日
0 收藏 692 点赞 2,262 浏览 2484 个字

Hunters

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

Problem DescriptionAlice 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. InputThe 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. OutputFor 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 Input3
2 1 0.5 0.5
2 1 0 1
7 7 0.32 0.16 Sample Outputtiger 1.7500
wolf 1.0000
tiger 6.5968 Source2012
Asia Tianjin Regional Contest
 Recommendzhoujiaqi2010   |   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得到的分数  x2.同理     

 #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 ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295