QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 16 MB 總分: 100 可 Hack ✓

#12344. 期望值

统计

有一个关于序列 $a_1, \dots, a_n$ 的游戏。在每一轮中,玩家等概率地随机选择一个位置 $i < n$,将元素 $a_i$ 替换为 $a_i - a_{i+1}$,然后从序列中移除元素 $a_{i+1}$。该过程持续进行,直到只剩下一个元素。求最后一个元素的期望值。

输入格式

第一行包含一个整数 $n$ ($2 \le n \le 4000$)。 第二行包含 $n$ 个整数 $a_1, \dots, a_n$ ($1 \le a_i \le 4000$)。

输出格式

如果答案为 $\frac{P}{Q}$ 且 $P$ 与 $Q$ 互质,输出一个整数,即 $(P \cdot Q^{-1}) \pmod{10^9 + 7}$。保证 $Q \not\equiv 0 \pmod{10^9 + 7}$。

样例

输入格式 1

2
2 1

输出格式 1

1

说明

请注意非标准的内存限制。

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.