Acdream. Bet (Mathematical deduction)

Source: Internet
Author: User

BetTime limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld &%l Lu SubmitStatusPracticeAcdream 1066

Description

The Josnch planet is a popular planet with a gambling wind.

Everyone is born with a certain amount of money, after all the income can only be obtained by gambling (OMG, if the RP is not good, gambled away all the money ...) )

Suppose a gambling company gambling has N results, each result can be obtained by the odds ratio is a[1],a[2]...a[n].

Assuming xxx has X dollars Now, ask him what strategy to choose to make the worst-case return the most?

Assuming that only one of the N results is in return, the X-dollar must all be used in this gamble, odds ratio is a[i], if you put in the results of the first y money, then you return is y * a[ I], the so-called strategy is how you should allocate your input on each outcome.

Example N = 2 When the odds ratio is 1, 2, you have a $, then buy the first 2000/3, after a 1000/3, so the worst case of your return is 666.67 .

Input

Multiple sets of data.

For each set of data, a number n (2≤n≤100),n is selected, the next line has n number, and the range of each number is 0.01 ~ 100.00 .

The last line is a number X (0.01≤x≤1000.00), which represents your total money.

Output

Each output line, the worst case maximum benefit, retains two decimal places.

Sample Input

21 21000

Sample Output

666.67

The students are very logical explanation: why when each return value of the same time (set at this time X), for the worst case of the maximum benefit.

Assuming that each return value is not exactly equal then there must be (>x) and (<x) elements, in the worst case, an element with a profit of (<x).

When the return value is all x, the worst yield is x > (<x) So when and only if the above conclusion .... Orz

Acdream. Bet (Mathematical deduction)

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.