問題一覧 > 通常問題

No.2516 Credit Creation

レベル : / AI推定難易度 : 159 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-9}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 169
作問者 : MasKoaTS / テスター : Shirotsume fky_
お気に入りにしたユーザー ProblemId : 8338 / 自分の提出
問題文最終更新日: 2023-10-25 10:49:11
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 410 (順位表) の他の問題:

Problem Statement

The Uribo Kingdom has $N$ banks numbered $1,2,\dots,N$.

In the Uribo Kingdom, the "beef" is used as the unit of currency, and amounts of it are represented by non-negative real values.

Initially, the deposit of bank $1$ is $100$ beef, and the deposits of all other banks are $0$ beef.
For these banks, the following operation is performed in the order $i=1,2,\dots,N$.

  • Let $x$ beef be the deposit of bank $i$. First, bank $i$ writes $x$ in its ledger. Next, if bank $i + 1$ exists, bank $i$ keeps $Rx$ beef on hand and deposits $(1 - R)x$ beef in bank $i+1$.

    After this operation, the deposit of bank $i+1$ is $(1-R)x$ beef.

The total deposit of the Uribo Kingdom is defined as the sum of the real numbers written in the ledgers during this process. Find this value.

Constraints

  • $2 \leq N \leq 100$

  • $N$ is an integer

  • $0 < R < 1$

  • $R$ is a real number with at most $2$ digits in its fractional part

Input

The input is given in the following format.

$N$
$R$
  • Line $1$ contains $N$

  • Line $2$ contains $R$

Output

Print the answer on $1$ line, followed by a newline.

The output is judged as correct if its absolute or relative error from the expected answer is at most $10^{−9}$.

It is guaranteed that the expected answer of this problem is always equal to the true value.

Sample

Sample 1
Input
3
0.05
Output
285.25

Initially, the deposit of bank $1$ is $100$ beef, and the deposits of banks $2, 3$ are both $0$ beef.

Bank $1$ writes the real number $100$ in its ledger, then deposits $100 \times (1 - 0.05) = 95$ beef in bank $2$.

As a result, the deposit of bank $2$ becomes $95$ beef.

Next, bank $2$ writes the real number $95$ in its ledger, then deposits $95 \times (1 - 0.05) = 90.25$ beef in bank $3$.

As a result, the deposit of bank $3$ becomes $90.25$ beef.

Finally, bank $3$ writes the real number $90.25$ in its ledger. Since bank $4$ does not exist, the operation ends here.

Therefore, the total deposit is $100 + 95 + 90.25 = 285.25$ beef.

Sample 2
Input
30
0.3
Output
333.325820219903102580637378917

It is guaranteed that the expected answer of this problem is always equal to the true value, but even if the printed value does not exactly match the expected answer,
it is judged as correct if its absolute or relative error from the expected answer is at most $10^{−9}$.

When using std::cout in C++, be careful about the number of digits displayed in the output value.

Sample 3
Input
100
0.99
Output
101.0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。