#abc251d. D - At Most 3 (Contestant ver.)

D - At Most 3 (Contestant ver.)

Score : 400400 points

问题描述

你得到一个整数 WW

你需要准备一些砝码,使得以下所有条件都得到满足:

  • 砝码的数量在 11300300(包含)之间。
  • 每个砝码的质量为不超过 10610^6 的正整数。
  • 区间 11WW(包含)内的每个整数都是一个 好整数。这里,一个正整数 nn 如果满足以下条件,则被称为好整数:
    • 我们可以从已准备好的砝码中选择 最多 3 个 不同的砝码,使得它们的总质量为 nn

输出一组满足条件的砝码组合。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are given an integer WW.
You are going to prepare some weights so that all of the conditions below are satisfied.

  • The number of weights is between 11 and 300300, inclusive.
  • Each weight has a mass of positive integer not exceeding 10610^6.
  • Every integer between 11 and WW, inclusive, is a good integer. Here, a positive integer nn is said to be a good integer if the following condition is satisfied:
    • We can choose at most 33 different weights from the prepared weights with a total mass of nn.

Print a combination of weights that satisfies the conditions.

Constraints

  • 1W1061 \leq W \leq 10^6
  • WW is an integer.

Input

Input is given from Standard Input in the following format:

WW

Output

Print in the following format, where NN is the number of weights and AiA_i is the mass of the ii-th weight. If multiple solutions exist, printing any of them is accepted.

NN

A1A_1 A2A_2 \dots ANA_N

Here, NN and A1,A2,,ANA_1,A_2,\dots,A_N should satisfy the following conditions:

  • 1N3001 \leq N \leq 300

  • 1Ai1061 \leq A_i \leq 10^6

Sample Input 1

6

Sample Output 1

3
1 2 3

In the output above, 33 weights with masses 11, 22, and 33 are prepared.
This output satisfies the conditions. Especially, regarding the 33-rd condition, we can confirm that every integer between 11 and WW, inclusive, is a good integer.

  • If we choose only the 11-st weight, it has a total mass of 11.
  • If we choose only the 22-nd weight, it has a total mass of 22.
  • If we choose only the 33-rd weight, it has a total mass of 33.
  • If we choose the 11-st and the 33-rd weights, they have a total mass of 44.
  • If we choose the 22-nd and the 33-rd weights, they have a total mass of 55.
  • If we choose the 11-st, the 22-nd, and the 33-rd weights, they have a total mass of 66.

Sample Input 2

12

Sample Output 2

6
2 5 1 2 5 1

You may prepare multiple weights with the same mass.

update @ 2024/3/10 10:43:00