PivotOJ

Crashing Competition Computer

시간 제한: 4000ms메모리 제한: 1024MB출처: BAPC 2022BOJ 25994

문제

You are writing code for a hackathon where you need to decode Binary ALGOL Punch Cards. You have already come up with the optimal solution and only need to type it out. The solution consists of cc characters, and your typing speed is 11 character per time unit. However, your computer is prone to sudden crashes: after every character you type there is a probability of pp that your computer crashes and you need to start over again. Recovering after a crash costs rr time units, and you can then continue typing from the last point where you saved your code.

You can click "Save" at any time (which costs tt time units) to save your code and to be able to restart from this point after crashes. Clicking "Save" will not cause your computer to crash.

Determine how many (expected) time units you need to complete the code. Note that the code should be saved after typing the last character.

입력

The input consists of:

  • One line with three integers cc, tt, and rr (1c20001 \leq c \leq 2000, 0t,r1090 \leq t, r \leq 10^9), indicating the number of characters, the time cost of clicking "Save", and the time cost of recovering after a crash.
  • One line with a floating-point number pp (0.001p0.9990.001 \leq p \leq 0.999, with at most 1010 digits after the decimal point), the probability that your computer crashes after a character press.

출력

Output the expected number of time units you need to complete the code.

Your answer should have an absolute or relative error of at most 10610^{-6}.

예제

예제 1

입력
2 1 5
0.25
출력
8.0

예제 2

입력
3 5 2
0.5
출력
26.0

예제 3

입력
10 4 5
0.327
출력
68.664967357
코드를 제출하려면 로그인하세요.