Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 2013-02-21 06:00:00.
Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.

DART - Dart Throw

Pistol Pete, the neighborhood game dealer, has offered to let you play his newest game. Pete's going to let you throw a dart at his wall containing several targets. Depending on what target you hit, you will win a fabulous prize!

You've been practicing a game like this lately, and you figure it's right up your alley. You will hit the target you aim at with prob percent probability. When you miss the target you aim at, you will hit either of the adjacent targets with equal probability. Since the targets are arranged in a circular fashion, if you miss target 0, then you will either hit target 1 or target n-1, where n is the total number of targets. See example 0 for clarification.

Pete has given you a sequence of integers: payout, in which the i-th element corresponds to the payout of hitting target i. You will also be given prob, the percent probability your dart will hit the target you aim for. The total number of targets is equal to the number of elements in payout. Given this information, find and print a number: the average payout that you will get from Pete if you play optimally.

Input Specification

The input will contain several test cases, each test cases will consist of two lines, the first will contain the payout sequence, the second will contain the given prob. You can assume the follow will be always true:

  • payout will contain between 3 and 50 elements, inclusive.
  • Each element of payout will be between 0 and 100, inclusive.
  • prob will be between 0 and 100, inclusive.

Output Specification

Print one line per test case with the answer, follow the format below. The result output must be truncated to five digits of precision

Input Example

10 40 50
80
10 40 50
61
20 1 18 4 13 6 10 15 2 17 3 19 7 16 8 11 14 9 12 5
60
20 1 18 4 13 6 10 15 2 17 3 19 7 16 8 11 14 9 12 5
20

Output Example

45.00000
40.25000
13.40000
15.40000

Added by:Fabio Avellaneda
Date:2013-02-02
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 JAVA
Public source code since: 2013-02-21 06:00:00

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.