QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 512 MB 총점: 100 해킹 가능 ✓

#16704. Hard Learning

통계

年轻的 Nick 明天有一堂文学课。他的作业是背诵一首诗。Nick 是一个著名的拖延症患者,所以他打算在临上课前才开始背诗,越晚越好。

这首诗由 $n$ 个诗节组成。背诵(学习)任何一个诗节恰好需要一分钟,之后朗诵它也恰好需要一分钟。如你所知,一个诗节你学习的次数越多,你记住它的时间就越长。Nick 知道,如果他第 $k$ 次(不一定连续)学习某个诗节,那么他将能够在接下来的 $k^2$ 分钟内完成对该诗节的朗诵。例如,如果他第一次学习某个诗节,他必须立即开始朗诵它。如果他稍后再次学习它(即第二次),他将在忘记它之前有三分钟的时间来开始朗诵。再下一次学习(第三次)后,他将有八分钟的时间来开始朗诵,依此类推。在连续两次学习同一个诗节之间发生什么并不重要,只有学习的次数会产生影响。

Nick 知道,上课一开始他就必须开始朗诵这首诗。他必须按顺序一个接一个地朗诵所有 $n$ 个诗节。Nick 需要在课前提前多少分钟开始学习,才能成功背诵并朗诵整首诗?

输入格式

输入一个整数 $n$ ($1 \le n \le 10\,000$),表示诗中的诗节数量。

输出格式

第一行输出一个整数 $k$,表示能够成功朗诵整首诗所需的最小学习时间(分钟数)。

第二行输出 $k$ 个介于 $1$ 到 $n$ 之间的整数,表示 Nick 应该学习诗节的顺序,以便能够按从第 $1$ 个到第 $n$ 个的顺序成功朗诵它们。

样例

输入样例 1

1

输出样例 1

1
1

输入样例 2

4

输出样例 2

8
1 2 3 4 1 2 3 4

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.