QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB

#21387. בעיית בנייה פשוטה

Statistics

עבור מספר שלם חיובי $n$, סדרה באורך $n$ נקראת ”סדרת לבנים אדומות“ אם היא מקיימת את התנאים הבאים:

  • כל אחד מהמספרים $1, 2, \ldots, n$ מופיע בסדרה בדיוק פעם אחת.
  • הסכום של כל זוג איברים סמוכים אינו ריבוע שלם.

בהינתן מספר שלם $n$, בנו סדרת לבנים אדומות באורך $n$.

קלט

השורה הראשונה מכילה מספר שלם $T$ ($1 \le T \le 10^4$), מספר מקרי הבדיקה.

עבור כל מקרה בדיקה, השורה היחידה מכילה מספר שלם $n$ ($1 \le n \le 4 \times 10^6$), האורך הנדרש של סדרת הלבנים האדומות.

מובטח כי סכום ערכי ה-$n$ אינו עולה על $4 \times 10^6$. ניתן להוכיח שתמיד קיים פתרון תחת האילוצים הנתונים.

פלט

הדפיסו $T$ שורות, שכל אחת מהן מכילה את הסדרה שיש לבנות. אם קיימות מספר תשובות, הדפיסו אחת מהן כלשהי.

דוגמאות

קלט 1

5
1
2
3
4
5

פלט 1

1
1 2
1 2 3
1 2 3 4
1 4 2 3 5

הערה

עבור $n = 5$, אם סדרת הפלט היא 1 2 3 4 5, זוהי תשובה שגויה מכיוון ש-$4 + 5 = 9$ הוא ריבוע שלם.

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.