QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100 Difficulté: [afficher]

#1807. 分配條狀物

Statistiques

有 $N$ 根金屬棒。第 $i$ 根金屬棒的重量為 $2i - 1$。

你的任務是將這些金屬棒分配到兩個或更多的組中,使得每組金屬棒的重量總和相同,或者判斷這是不可能的。請注意,每根金屬棒必須恰好分配到一個組中,且不允許切割金屬棒。

輸入格式

輸入包含一個整數 $N$ ($2 \le N \le 10^5$)。

輸出格式

如果無法將金屬棒分配到兩個或更多重量相等的組中,請輸出一行包含整數 $-1$。

否則,在第一行輸出組數 $G$ ($2 \le G \le N$)。接著輸出 $G$ 行,每行對應一個組。第 $i$ 行必須以整數 $K_i$ 開頭,表示第 $i$ 組中金屬棒的數量。接著輸出 $K_i$ 個整數:該組中金屬棒的重量。每根金屬棒必須恰好分配到一個組中,且所有組中金屬棒的重量總和必須相同。

如果存在多種解,輸出其中任意一種即可。

範例

範例輸入 1

4

範例輸出 1

2
2 1 7
2 3 5

範例輸入 2

2

範例輸出 2

-1

範例輸入 3

3

範例輸出 3

-1

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.