#P11014. Furina's Expectation Summation
Furina's Expectation Summation
Furina's Expectation Summation
Define a function \(a(x)\) that returns the sum of the distinct prime factors of a natural number \(x\). In particular, if \(x = \prod_{p \in \mathbb{P}} p^{d_p}\), then \[ a(x) = \sum_{p \in \mathbb{P}} p \cdot [d_p \ge 1], \] with \(a(1) = 0\).
From the very first day, Furina has an initial expectation value \(m_1\). For each subsequent day \(i\) (with \(2 \le i \le n\)), she updates her expectation value as follows: \[ m_i = \max_{1 \le j < i}\left\{ \frac{m_j}{a(\operatorname{lcm}(w_i, w_j)) + a(\operatorname{gcd}(w_i, w_j))} \right\} + k, \] where \(w_i\) is the weight associated with day \(i\) and \(k\) is an extra expectation value earned from watching the judgment.
Your task is to calculate the sum \[ S = \sum_{i=1}^{n} m_i. \]
inputFormat
The first line contains three numbers: an integer \(n\) (the number of days), a real number \(k\) (the bonus expectation value), and a real number \(m_1\) (the expectation value on the first day).
The second line contains \(n\) positive integers: \(w_1, w_2, \ldots, w_n\), where \(w_i\) is the weight for day \(i\).
outputFormat
Output a single number, the value of \(S = \sum_{i=1}^{n} m_i\), formatted to 5 decimal places.
sample
2 1 1
2 3
2.20000