QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 100

#12997. 期望 LCP

统计

考虑一个包含 $n$ 个无限长二进制字符串(即仅由 0 和 1 组成)的序列 $s_1, s_2, \dots, s_n$,其中每个字符串的每个字符都是独立且均匀随机生成的。记 $$f(s_1, s_2, \dots, s_n) = \max_{1 \le i < j \le n} LCP(s_i, s_j)$$ 其中 $LCP$ 表示两个字符串的最长公共前缀长度。计算 $f(s_1, s_2, \dots, s_n)$ 的期望值。

输入仅包含一行,为一个整数 $n$ ($2 \le n \le 10^4$)。

将答案表示为最简分数 $P/Q$。输出 $P \cdot Q^{-1} \pmod{10^9 + 7}$。保证 $Q \pmod{10^9 + 7} \neq 0$。

样例

输入格式 1

2

输出格式 1

1

输入格式 2

3

输出格式 2

333333338

说明

注意期望值总是有限的,即 $E[f(s_1, \dots, s_n)] < \infty$。

在第二个样例中,答案为 $7/3$。

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.