問題一覧 > 通常問題

No.2461 All on One

レベル : / AI推定難易度 : 550 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 155
作問者 : 👑 Nachia / テスター : 👑 Kazun
お気に入りにしたユーザー ProblemId : 5707 / 自分の提出
問題文最終更新日: 2023-09-03 13:50:39
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 404 (順位表) の他の問題:

Problem Statement

In the gacha of a certain social game, each time you roll it $1$ time, you obtain a "Rare Character" with probability $p$ by an independent draw. In parallel with this, rolling this gacha $K$ times guarantees that you obtain a "Rare Character". Suppose you keep rolling this gacha until you obtain a "Rare Character". Compute the expected value of the number of rolls.

Answer for $T$ test cases.

Input

Line $1$ contains an integer $T$. Then, $T$ test cases follow.

Each test case is given in the following format.

$p$ $K$

The input satisfies the following constraints.

  • $T$ is an integer, $1 \le T \le 1000$
  • $p$ has at least $1$ and at most $3$ digits in its fractional part (including trailing $0$s), $0 \le p \le 1$
  • $K$ is an integer, $1 \le K \le 500$

Output

For each test case, print the real number that is the answer as a decimal on $1$ line. There is reference data created so that its absolute or relative error from the true value is at most $10^{-10}$; the value output by the submitted program is accepted if its absolute or relative error with respect to that data is at most $10^{-5}$. Print a newline at the end.

Sample

Sample 1
Input
4
0.5 2
1.0 100
0.7 5
0.002 500
Output
1.50000000000
1.00000000000
1.42510000000
316.24437257142

Explanation of test case 1. When you roll the gacha $1$ time, you obtain a "Rare Character" with probability $0.5$. If you did not obtain it, you are guaranteed to obtain a "Rare Character" on roll number $2$. The probability of rolling exactly $1$ time is $0.5$ and the probability of rolling $2$ times is $0.5$, so the desired expected value is $1 \times 0.5+2 \times 0.5=1.5$.

Explanation of test case 2. When you roll the gacha $1$ time, you obtain a "Rare Character" with probability $1$. There is no possibility of rolling the gacha $2$ or more times.

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