QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#889. 彷徨い

統計

Rikkaは優秀な学生です。

彼女はICPCの問題を解きながら廊下を歩き回るのが好きです。具体的には、$n$ ステップのランダムウォークを行います。$i$ 番目のランダムステップにおいて、彼女は $x, y \in \mathbb{R}$ かつ $x^2 + y^2 \le R_i^2$ を満たすベクトル $(x, y)$ を等確率で選択します。そして、そのベクトルに沿って歩きます。言い換えれば、ランダムステップの前に $(A, B)$ に立っていた場合、ステップ後には $(A + x, B + y)$ に立っていることになります。歩き始める前、彼女はドアの地点 $(0, 0)$ に立っています。

歩き終わった後、彼女は点 $(0, 0)$ までのユークリッド距離の2乗の期待値に興味を持ちました。言い換えれば、すべての $n$ ステップのランダムウォークを終えた後に彼女が $(x, y)$ に立っているとき、$x^2 + y^2$ の期待値を知りたいと考えています。

入力

1行目には、ランダムステップの回数を表す整数 $n$ が含まれます。 2行目には、$i$ 番目のランダムステップのパラメータである $n$ 個の正の整数 $R_i$ が含まれます。

制約は $1 \le n \le 50\,000$ および $1 \le R_i \le 1000$ です。

出力

$x^2 + y^2$ の期待値 $d$ を出力してください。正解を $d^*$ としたとき、$\frac{|d - d^*|}{\max\{d^*, 1\}} \le 10^{-6}$ を満たす必要があります。

入出力例

入力 1

3
1 2 3

出力 1

7.000000000000000

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.