QOJ.ac

QOJ

Time Limit: 5.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#16110. Joyeuse

Statistics

在一场盛大而耀眼的舞会上,有 $N$ 位客人,每位客人都有各自的舞蹈技能值 $a_i$。

当两位客人配对在舞池中跳舞时,他们的表现分等于他们技能值之和的平方根。例如,如果一位客人的技能值为 $4$,另一位为 $5$,他们的二重奏表现分为 $\sqrt{4 + 5} = 3$。

作为这场生动庆典的主办方,你希望衡量集体的快乐程度——即每一对可能的客人组合恰好跳一次舞时的总表现分。

你的任务是计算这个总分。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 200000$),表示客人的数量。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$),表示客人的舞蹈技能值。

输出格式

输出一个实数,表示舞会上的总表现分。

如果相对误差不超过 $10^{-6}$,则答案被视为正确。

样例

输入 1

5
7 3 11 2 17

输出 1

39.009712

说明

所有可能的配对及其表现分如下:

客人 1 和客人 2:$\sqrt{7 + 3} \approx 3.162277660$ 客人 1 和客人 3:$\sqrt{7 + 11} \approx 4.242640687$ 客人 1 和客人 4:$\sqrt{7 + 2} = 3$ 客人 1 和客人 5:$\sqrt{7 + 17} \approx 4.898979486$ 客人 2 和客人 3:$\sqrt{3 + 11} \approx 3.741657387$ 客人 2 和客人 4:$\sqrt{3 + 2} \approx 2.236067977$ 客人 2 和客人 5:$\sqrt{3 + 17} \approx 4.472135955$ 客人 3 和客人 4:$\sqrt{11 + 2} \approx 3.605551275$ 客人 3 和客人 5:$\sqrt{11 + 17} \approx 5.291502622$ 客人 4 和客人 5:$\sqrt{2 + 17} \approx 4.358898944$

将它们全部相加得到约 $39.009712$。

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.