luogu#P2674. 《瞿葩的数字游戏》T2-多边形数
《瞿葩的数字游戏》T2-多边形数
Background
In the Kingdom of Numbers, there is a special class of numbers called polygonal numbers. King also decreed that marriages between numbers can only happen within the same type of polygonal numbers. (Please don't complain about this rule...)
Qupa became very curious about this phenomenon. Seeing the couple and taking a walk, Qupa asked which kind of polygonal number it was. But patted its head and said, "I don't know either. Go ask the king."
It seems the citizens do not know which polygonal numbers they are, and King is worried. King only knows how to compute polygonal numbers, but how should he explain this to the citizens? He decides to explain it this way: any integer that can be arranged into a regular polygon is a polygonal number. Polygonal numbers include triangular numbers, square numbers, pentagonal numbers, hexagonal numbers, and so on.
Problem Description
This is a pattern-finding problem. Please discover the pattern yourself to practice mathematical induction!!
Let’s take triangular numbers as an example: the numbers , , , in the figure are triangular numbers.

Task: determine which kinds of polygonal numbers belongs to (assume is a -gonal number). For example, we can find that is both a triangular number and a square number. If it is not a polygonal number, output Poor + that number. If it is multiple types of polygonal numbers at the same time, output the smallest and the second smallest . Each input file contains test cases.
Input Format
First a number , then lines, each containing one integer.
Output Format
Output lines. For each , output the corresponding and . If is not a polygonal number, output Poor + that number (no spaces in between).
2
36
1000000
3 4
4 204
Hint
Constraints and Notes
For of the testdata, .
For of the testdata, , .
If is multiple types of polygonal numbers at the same time, let be the smallest , and be the second smallest .
King : "Can you discover the pattern that square numbers are just perfect squares? To make it easier to understand, I’ll provide a table of the first few polygonal numbers." (From the table you can see that a regular hexagon does not include the very center point, and similarly for others.)
| Natural numbers | ||||||||
|---|---|---|---|---|---|---|---|---|
| Triangular numbers | ||||||||
| Square numbers | ||||||||
| Pentagonal numbers | ||||||||
| Hexagonal numbers |
Translated by ChatGPT 5