eolymp
bolt
Try our new interface for solving problems
Məsələlər

Poly-polygonal Numbers

Poly-polygonal Numbers

A \textit{polygonal} number is a number which can be represented by a regular geometrical arrangement of equally spaced points, where the arrangement forms a regular polygon. Some examples are shown in the gure below. \includegraphics{https://static.e-olymp.com/content/20/20b479fb0a716f6eccb241776e84c1b883a36d30.jpg} The first figure shows the first \textbf{4} \textit{triangular} numbers \textbf{1}, \textbf{3}, \textbf{6}, \textbf{10}. The next three show the first four \textit{square}, \textit{pentagonal }and \textit{hexagonal} numbers, respectively. In general, \textbf{k}-\textit{gonal} numbers are those whose points de ne a regular \textbf{k}-gon (hence triangular numbers are \textbf{3}-gonal, square numbers are \textbf{4}-gonal, etc.). We will de ne \textbf{k} as an \textit{index} of the polygonal number. For this problem, you are to find numbers which are \textbf{k}-gonal for two or more values of \textbf{k}. We will call these numbers \textit{poly-polygonal}. \InputFile Input will consist of multiple problem instances. Each instance will consist of \textbf{3} lines. The first line will be a non-negative integer \textbf{n} ≤ \textbf{50} indicating the number of types of polygonal numbers of interest in this problem. Note that this line may be longer than \textbf{80} characters. The next line will contain \textbf{n} integers indicating the indices of these polygonal numbers (all distinct and in increasing order). For example, if the first line contained the value \textbf{3}, and the next line contained the values \textbf{3 6 10}, then that problem instance would be interested in \textbf{3}-gonal, \textbf{6}-gonal and \textbf{10}-gonal numbers. Each index \textbf{k} will lie in the range \textbf{3} ≤ \textbf{k} ≤ \textbf{1000}. The last line of the problem instance will consist of a single positive integer \textbf{s} ≤ \textbf{10000}, which serves as a starting point for the search for poly-polygonal numbers. A value of \textbf{n = 0} terminates the input. \OutputFile For each problem instance, you should output the next \textbf{5} poly-polygonal numbers which are greater than or equal to \textbf{s}. Each number should be on a single line and conform to the following format: \textbf{num:k_1 k_2 k_3 ...} where \textbf{num} is the poly-polygonal number, and \textbf{k_1}, \textbf{k_2}, \textbf{k_3} ... are the indices (in increasing order) of the poly-polygonal number equal to num. A single space should separate each index, and you should separate each problem instance with a single blank line. The judges input will be such that the maximum value for any poly-polygonal number will \textbf{ t} in a long variable.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 128 MiB
Giriş verilənləri #1
10
6 7 8 9 10 11 12 13 14 15
1000
5
3 4 13 36 124
1
0
Çıxış verilənləri #1
1216:9 12
1540:6 10
1701:10 13
2300:11 14
3025:12 15

1:3 4 13 36 124
36:3 4 13 36
105:3 36
171:3 13
1225:3 4 124
Mənbə ACM ICPC East Central Regional Contest 2000