博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Hunters
阅读量:4686 次
发布时间:2019-06-09

本文共 2866 字,大约阅读时间需要 9 分钟。

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
 
1 #include 
2 #include
3 4 int main() 5 { 6 int T,X,Y; 7 double Q,P,tiger,wolf; 8 scanf("%d",&T); 9 while(T--)10 {11 getchar();12 scanf("%d%d%lf%lf",&X,&Y,&P,&Q);13 tiger=(1-Q)*X+Q*P*(X+Y);14 wolf=Q*Y+(1-Q)*P*(X+Y);15 if(tiger>wolf)16 printf("tiger %.4lf\n",tiger);17 else18 printf("wolf %.4lf\n",wolf);19 }20 return 0;21 22 }
View Code

 

转载于:https://www.cnblogs.com/Wurq/p/3750281.html

你可能感兴趣的文章
ultraedit26 运行的是试用模式_免费试用U盘数据恢复工具 – 轻松找回U盘丢失的各种数据!...
查看>>
python sum函数导入list_python sum函数iterable参数为二维list,start参数为“[]”该如何理解...
查看>>
UVa540 Team Queue
查看>>
android 练习之路 (八)
查看>>
tp5 中 model 的聚合查询
查看>>
android wear开发之:增加可穿戴设备功能到通知中 - Adding Wearable Features to Notifications...
查看>>
压缩文件函数库(转载)
查看>>
【转】ubuntu12.04没有/var/log/messages解决
查看>>
Oracle EBS 初始化用户密码
查看>>
SYS_CONTEXT 详细用法
查看>>
Pycharm配置autopep8让Python代码更符合pep8规范
查看>>
函数的复写
查看>>
17_重入锁ReentrantLock
查看>>
winform窗口关闭提示
查看>>
64款工具,总有合适您的那款
查看>>
我的第一篇博客
查看>>
大数据学习线路整理
查看>>
【C++算法与数据结构学习笔记------单链表实现多项式】
查看>>
关于ProjectServer定制化项目中心页面
查看>>
使用Collectd + InfluxDB + Grafana进行JMX监控
查看>>