QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 1024 MB 总分: 100 可 Hack ✓

#18033. 不许插队!!!

统计

据说京畿科学高中的伙食美味程度堪比酒店餐厅。像往常一样,Pickle 正在排队等待用餐,队伍排得很长。然而,站在 Pickle 身后的其中一个人——Jaewoo,因为无法忍受等待,试图插队!Pickle 绝不允许任何人破坏排队顺序,如果插队被发现,Jaewoo 将难逃惩罚。

在插队发生前,Pickle 和 Jaewoo 之间有 $N$ 个人。插队通过重复以下操作进行:

当前 Pickle 和 Jaewoo 之间有 $n$ 个人时,如果 Jaewoo 试图越过 $k$ 个人,Pickle 将以 $\frac{k}{n + 1}$ 的概率抓住 Jaewoo。如果在此次操作中 Jaewoo 没有被抓住,那么他和 Pickle 之间的人数将减少 $k$ 个,变为 $n - k$ 人。(其中 $1 \le k \le n$)如果通过 $X$ 次插队操作,Jaewoo 成功越过了 $N$ 个人并到达了 Pickle 的正后方,Pickle 就再也无法察觉 Jaewoo 的行为了。

我们希望 Jaewoo 能平安无事,因此想告诉他如何插队才能使被 Pickle 抓住的概率最低。请计算出在最安全的插队方式下,插队操作的次数以及每次操作中越过的人数。如果存在多种答案,输出其中任意一种即可。

输入格式

给定初始时 Pickle 和 Jaewoo 之间的人数 $N$。

$1 \leq N \leq 10^5$

输出格式

第一行输出 Jaewoo 被 Pickle 抓住的概率最低时,插队操作的次数 $X$。

第二行输出 $X$ 个整数 $k_1,\ k_2, \cdots,\ k_X$,以空格分隔。其中 $k_i$ 表示 Jaewoo 第 $i$ 次插队时越过的人数。$(1 \le i \le X)$

子任务

  1. $N\le 3$ (30分)

  2. $N\le 10$ (30分)

  3. 无额外限制。(40分)

样例

样例输入 1

4

样例输出 1

2
2 2

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.