QOJ.ac

QOJ

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

#889. 방랑

統計

Rikka는 재능 있는 학생입니다.

그녀는 ICPC 문제를 풀면서 복도를 거니는 것을 좋아합니다. 구체적으로, 그녀는 $n$번의 단계 동안 무작위 보행(random walk)을 합니다. $i$번째 무작위 단계에서, 그녀는 $x, y \in \mathbb{R}$이고 $x^2 + y^2 \leq R_i^2$를 만족하는 벡터 $(x, y)$ 중 하나를 동일한 확률로 선택합니다. 그리고 그 벡터를 따라 이동합니다. 즉, 무작위 단계 이전에 $(A, B)$에 서 있었다면, 이동 후에는 $(A + x, B + y)$에 서 있게 됩니다. 보행을 시작하기 전, 그녀는 문 $(0, 0)$에 서 있습니다.

보행을 마친 후, 그녀는 원점 $(0, 0)$까지의 유클리드 거리의 제곱에 대한 기댓값이 궁금해졌습니다. 다시 말해, $n$번의 모든 무작위 단계가 끝난 후 그녀가 $(x, y)$에 서 있을 때, $x^2 + y^2$의 기댓값을 알고 싶어 합니다.

입력

첫 번째 줄에는 무작위 단계의 수인 정수 $n$이 주어집니다.

두 번째 줄에는 $i$번째 무작위 단계의 매개변수인 $n$개의 양의 정수 $R_i$가 주어집니다.

$1 \leq n \leq 50\,000$이고 $1 \leq R_i \leq 1000$임이 보장됩니다.

출력

$x^2 + y^2$의 기댓값인 $d$를 출력해야 합니다. 정답을 $d^*$라고 할 때, $\frac{|d - d^*|}{\max\{d^*, 1\}} \leq 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.