HDU 4438 Hunters Regional Water problem

Source: Internet
Author: User

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

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.