QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 256 MB Puntuación total: 100

#4527. Terrifying Slave Owner

Estadísticas

"A fight? Count me in!"

"Everyone, get in here!"

The Grim Patron is saddened by the nerf to Warsong Commander and decides to commemorate her with a math problem.

Let $\{u_i\}$ be a sequence defined by:

\begin{equation} u_i = a + \frac{b}{u_{i-1}} + \frac{c}{u_{i-1}u_{i-2}} \quad (i \geq 2) \end{equation}

Given $u_0, u_1, a, b, c, n$. It is guaranteed that $x^3 = a x^2 + b x + c$ has $3$ distinct positive integer roots.

Find $u_n$.

Input

The input consists of a single line containing $6$ integers: $u_0, u_1, a, b, c, n$.

Output

Output a single line containing $1$ integer (or decimal), with at least 8 and at most 15 decimal places. Your answer is considered correct if the absolute difference between your answer and our answer is no more than $10^{-6}$. Considering the inherent errors in floating-point arithmetic, you are guaranteed to be correct if your answer differs from the true answer by no more than $10^{-6} - 10^{-8}$.

Examples

Input 1

-7 29 31 -311 1001 100

Output 1

11.00000000

Constraints

For 100% of the data, $c \leq 100000$, $|u_0| \leq 1000$, $|u_1| \leq 1000$, $0 \leq n \leq 10^9$.

For 40% of the data, $n \leq 20$.

Note

You may ignore this section.

Because floating-point numbers are stored using significant digits, most decimal numbers already contain errors from the moment they are read. Subtraction operations used to determine absolute error also produce truncation errors at the end when the exponents of the two numbers differ.

Let $\delta_1$ be the error generated during the process of comparing your answer with the reference answer. In most cases, we can only treat this value as a random variable and estimate its upper bound $\epsilon_1$. For example, in this problem, we can prove $\epsilon_1 \leq 10^{-8}$, i.e., $|\delta_1| \leq 10^{-8}$.

Let the tolerance range be $\epsilon_2$, which is the parameter we use in practice to judge equality; in this problem, $\epsilon_2 = 10^{-6}$. If the absolute difference between your answer and the true answer does not exceed $\epsilon_2 - \epsilon_1$, we guarantee that you will receive points. If the absolute difference exceeds $\epsilon_2 + \epsilon_1$, you will definitely not receive points. If the difference falls between these two values, we cannot guarantee whether you will receive points; you can only hope that the machine-generated error and your own error are close enough to allow you to pass.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.