QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#889. 漫游

Statistics

Rikka 是一位天才学生。

她喜欢在解决 ICPC 问题时在走廊里漫步。具体来说,她将进行 $n$ 步随机游走。在第 $i$ 步随机游走中,她会等概率地选择一个向量 $(x, y)$,满足 $x, y \in \mathbb{R}$ 且 $x^2 + y^2 \le R_i^2$。然后她会沿着该向量行走。换句话说,如果她在随机游走前站在 $(A, B)$,那么之后她将站在 $(A + x, B + y)$。在漫步开始前,她站在门口 $(0, 0)$。

漫步结束后,她对到点 $(0, 0)$ 的欧几里得距离的平方的期望值感到好奇。换句话说,她想知道在完成所有 $n$ 步随机游走后,如果她站在 $(x, y)$,那么 $x^2 + y^2$ 的期望值是多少。

输入

第一行包含一个整数 $n$,表示随机游走的步数。 第二行包含 $n$ 个正整数 $R_i$,表示第 $i$ 步随机游走的参数。 保证 $1 \le n \le 50\,000$ 且 $1 \le R_i \le 1000$。

输出

你需要输出 $d$,即 $x^2 + y^2$ 的期望值。假设正确结果为 $d^*$,你需要确保 $\frac{|d - d^*|}{\max\{d^*, 1\}} \le 10^{-6}$。

样例

输入

3
1 2 3

输出

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.