#P2674. 《瞿葩的数字游戏》T2-多边形数

《瞿葩的数字游戏》T2-多边形数

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 11, 33, 66, 1010 in the figure are triangular numbers.

Task: determine which kinds of polygonal numbers NN belongs to (assume NN is a KK-gonal number). For example, we can find that 3636 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 KK and the second smallest KK. Each input file contains ngng test cases.

Input Format

First a number ngng, then ngng lines, each containing one integer.

Output Format

Output ngng lines. For each NN, output the corresponding K1K_1 and K2K_2. If NN 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 20%20\% of the testdata, 1K1,K261 \le K_1, K_2 \le 6.

For 100%100\% of the testdata, 1N1061 \le N \le 10^6, 1ng1021 \le ng \le 10^2.

If NN is multiple types of polygonal numbers at the same time, let K1K_1 be the smallest KK, and K2K_2 be the second smallest KK.

King 11: "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 11 22 33 44 55 66 77 88
Triangular numbers 11 33 66 1010 1515 2121 2828 3636
Square numbers 44 99 1616 2525 3636 4949 6464
Pentagonal numbers 55 1212 2222 3535 5151 7070 9292
Hexagonal numbers 66 1515 2828 4545 6666 9191 120120

Translated by ChatGPT 5