QOJ.ac

QOJ

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

#11960. 组合节奏

Statistics

节奏是音乐的重要组成部分,对于有抱负的音乐家来说,理解节奏至关重要。随着音乐家技能的提高,他们会接触到更复杂的节奏。为了简化音乐片段的学习,一种简化节奏的方法可能会有所帮助。其中一种方法是将节奏分解为由 2 个或 3 个节拍组成的组。

节奏由多个节拍组成。单个节拍无法构成节奏,因为节拍之间是相互依赖的。节奏可以细分为更小的部分。例如,7 个节拍的节奏可以细分为 4 个节拍和 3 个节拍,或者细分为 2、3 和 2 个节拍。然而,7 个节拍的节奏不能细分为 1、3 和 3 个节拍,因为其中一个部分无法构成节奏。

这使得 2 成为我们可以用来分解节奏的最小节拍组大小,但如果我们只使用大小为 2 的组,就无法处理奇数个节拍的情况。将 3 作为组大小,使我们能够分解任何节奏,即使它有奇数个节拍。

给定一个节奏中的节拍总数,请提供一种将其分解为大小为 2 和 3 的组的方法。

图片由 Gunnlaugur Arnarson 提供

输入格式

输入的第一行也是唯一一行包含一个整数 $N$ ($2 \le N \le 10^6$),表示节奏中的节拍总数。

输出格式

首先输出一行,包含一个整数 $K$,表示你的分解方案中包含的组数。然后输出一行,包含 $K$ 个用空格分隔的整数,每个整数均为 2 或 3。你的分解方案必须包含正确总数的节拍。

如果存在多种正确的答案,你可以输出其中任意一种。

样例

样例输入 1

25

样例输出 1

9
3 3 3 3 3 3 2 2 3

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.