#abc251d. D - At Most 3 (Contestant ver.)
D - At Most 3 (Contestant ver.)
Score : points
问题描述
你得到一个整数 。
你需要准备一些砝码,使得以下所有条件都得到满足:
- 砝码的数量在 到 (包含)之间。
- 每个砝码的质量为不超过 的正整数。
- 区间 到 (包含)内的每个整数都是一个 好整数。这里,一个正整数 如果满足以下条件,则被称为好整数:
- 我们可以从已准备好的砝码中选择 最多 3 个 不同的砝码,使得它们的总质量为 。
输出一组满足条件的砝码组合。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given an integer .
You are going to prepare some weights so that all of the conditions below are satisfied.
- The number of weights is between and , inclusive.
- Each weight has a mass of positive integer not exceeding .
- Every integer between and , inclusive, is a good integer. Here, a positive integer is said to be a good integer if the following condition is satisfied:
- We can choose at most different weights from the prepared weights with a total mass of .
Print a combination of weights that satisfies the conditions.
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print in the following format, where is the number of weights and is the mass of the -th weight. If multiple solutions exist, printing any of them is accepted.
Here, and should satisfy the following conditions:
Sample Input 1
6
Sample Output 1
3
1 2 3
In the output above, weights with masses , , and are prepared.
This output satisfies the conditions. Especially, regarding the -rd condition, we can confirm that every integer between and , inclusive, is a good integer.
- If we choose only the -st weight, it has a total mass of .
- If we choose only the -nd weight, it has a total mass of .
- If we choose only the -rd weight, it has a total mass of .
- If we choose the -st and the -rd weights, they have a total mass of .
- If we choose the -nd and the -rd weights, they have a total mass of .
- If we choose the -st, the -nd, and the -rd weights, they have a total mass of .
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