QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#13991. 神秘序列

統計

_E.Space_ had a dream.

He dreamt about a magic sequence. Someone had told him that this sequence was closely related to the examination tomorrow. He made up his mind to memorize it.

However, after waking up, _E.Space_ found that he had forgot that magic sequence; but fortunately, he remembered that the sequence has an interesting property.

In the dream, _E.Space_ applied to the sequence a series of operations.

The sequence was denoted by $a_1,a_2,\cdots,a_n$. Initially, $\forall~1\le i \le n$, $a_i\ge0$ and $a_n\ne 0$.

Later on, _E.Space_ chose an $i$ satisfying $a_i=i$ during each operation, setting $a_i$ to $0$, and increasing $a_1,a_2,\cdots,a_{i-1}$ by $1$, respectively.

_E.Space_ remembers that, after $n+k$ operations, the sequence had been transformed into a zero sequence, that is, $a_1=a_2=\cdots=a_n=0$.

He knows that there may be multiple sequences satisfying that property, but he still wishes you to tell him a possible one. You never know, all sequences like that work in the exam.

His grade is now in charge of you.

Input Format

One line, a positive integer $k$.

Output Format

If you find any sequences with the property _E.Space_ described above, output two lines.

On the first line, output a positive integer $n$.

On the second line, print $n$ nonnegative integers, $a_1,a_2,\cdots,a_n$, where $a_n\ne 0$, denoting one possible magic sequence.

If there exist multiple ones, print any.

If there is no possible sequence, output one line, including only a string Daydream!, to tell _E.Space_ that he had a daydream.

Sample

Input

1

Output

2
1 2

Sample

Input

5

Output

4
1 2 2 4

Subtasks

Subtask 1 (10 points): $k\le 6$.

Subtask 2 (25 points): $k\le 10^6$.

Subtask 3 (30 points): $k\le 10^{11}$, and it is guaranteed that there is a solution satisfying $\forall 1\le i < n,~a_i\ne i$, if any solution exists.

Subtask 4 (28 points): $k\le 10^{11}.$

Subtask 5 (7 points): $k\le 10^{12}$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#501EditorialOpen来自仓库的文档Qingyu2026-01-01 10:32:56View

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.