HDU 4438 hunters 37th ACM/ICPC Tianjin Division Field Competition H question (super water question)

Source: Internet
Author: User
Hunters

Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 21 accepted submission (s): 17

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'tknown 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 shoshould choose and the highest expected score she can get, in one line, separated by a space. the expected score shocould 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 This question is the most watery question in the semi-finals. who first discovered this question? Who is the one with 800 yuan FB .... No more questions about water. Two expectations: (1-Q) * x + Q * p * (x + y) Q * Y + (1-Q) * p * (x + y) It is better to compare which one is big ....
# Include <stdio. h> # Include < String . H> # Include <Algorithm># Include <Iostream> Using   Namespace  STD;  Int  Main (){  Int  X, Y;  Double  P, q;  Int  T; scanf (  "  % D  " ,& T ); While (T -- ) {Scanf (  "  % D % lf  " , & X, & Y, & P ,& Q );  Double Ans1 = ( 1 -Q) * x + Q * (p * x + p * Y );  Double Ans2 = Q * Y + ( 1 -Q) * (p * x + p * Y );  If (Ans1> ans2) printf ("  Tiger %. 4lf \ n  "  , Ans1 );  Else Printf ( "  Wolf %. 4lf \ n  "  , Ans2 );}  Return   0  ;} 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.