This article is reproduced in http://blog.csdn.net/major_zhang/article/details/521975382012 Tianjin regional competition The most water problem:
Test instructions easy to read, and then is to find a score of the mathematical expectation, so-called mathematical expectation is the average score under the probability.
Now there are two options, Alice to choose the best solution according to the data given by the input, that is, the first choice of tigers, or wolves.
1.A First Tiger Selection:
A.B also first select the tiger, then the score is Q (p*x+p*y); After playing the Tiger and playing the wolf
B.b Choose the Wolf, then two people can directly obtain prey, then the score is (1-Q) *x
So the 1 scheme Alice first chooses the tiger's score expectation is a+b; (mathematics expects the probability of each case to add up to 1, here to Bob's choice as a watershed, easy to draw)
2.A First Choice Wolf:
A.B first ...
B.B First ...
Then compare the scores of A and B to expect that high, choose which option, and the output also gives a hint, that is, the choice of Tiger and Wolf score.
#include <iostream>#include<cstdio>using namespacestd;intMain () {intT; CIN>>T; while(t--){ Doubleb; Doublex,y,p,q; CIN>>x>>y>>p>>Q; A=q* (p*x+p*y) + (1-Q) *x; b=(1-Q) * (p*x+p*y) +y*Q; if(a>b) printf ("Tiger%.4f\n", a); Elseprintf ("Wolf%.4f\n", B); } return 0;}
HDU 4438 Hunters Regional Water problem