QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 256 MB مجموع النقاط: 100

#2058. 生成器

الإحصائيات

考虑如下生成 $2$ 到 $N$ 之间随机素数的算法:

  1. 从区间 $[2, N]$ 中随机选择一个整数 $x$。对于所有 $N - 1$ 个整数,被选中的概率相同。
  2. 检查 $x$ 是否为素数。如果是,执行第 3 步;否则,回到第 1 步。
  3. 返回 $x$ 作为结果。

为了检查 $x$ 是否为素数,使用以下算法:

  1. 令 $d := 2$。
  2. 如果 $d$ 大于 $x$ 的平方根,即 $d^2 > x$,则终止过程并判定 $x$ 为素数。否则,执行第 3 步。
  3. 检查 $x$ 是否能被 $d$ 整除。如果能,则终止过程并判定 $x$ 不是素数。否则,令 $d := d + 1$ 并回到第 2 步。

对于给定的 $N$,求出在第二个算法的第 3 步中进行除法运算次数的期望值。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试用例的数量。 每个测试用例占一行,包含一个整数 $N$ ($2 \le N \le 10^7$)。

输出格式

对于每个测试用例,以既约分数的形式输出答案。

样例

样例输入 1

6
2
3
4
5
6
10

样例输出 1

0/1
0/1
1/2
2/3
1/1
2/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.