#P6904. Largest Stock Price Decline

    ID: 20111 Type: Default 1000ms 256MiB

Largest Stock Price Decline

Largest Stock Price Decline

Fatima Cynara, an analyst at Amalgamated Artichokes (AA), wants to determine the largest decline in stock prices over a given sequence. The stock prices over time are modeled by the formula:

\( \operatorname{price}(k) = p \cdot (\sin(a\cdot k+b) + \cos(c\cdot k+d) + 2) \)

for integer values of \(k\). The decline is defined as the difference between an earlier price and a later lower price. If there is no decline, output 0.

inputFormat

The input consists of two lines:

1. The first line contains an integer \(n\) (\(n \ge 2\)) which represents the number of stock prices to consider, evaluated at \(k = 0, 1, \dots, n-1\).

2. The second line contains five space-separated real numbers: \(p\), \(a\), \(b\), \(c\), and \(d\>.

outputFormat

Output a single real number representing the largest decline observed between any two prices (where the earlier price is higher than a later one). If no decline is observed, output 0. The answer should be accurate within an error margin of \(10^{-6}\).

sample

5
1 0 0 0 0
0.000000