eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Maze movement

Maze movement

Your boss gave you the task of creating a walking maze, and you are evaluating different designs. Before you commit to one, you want to know how quickly people can move in and out of each different maze. After all, your boss is interested in making money on this venture and, the faster people can move through, the more paying customers you can handle. A maze is a set of numbered rooms and passages connecting the rooms. The maze’s only entrance is at the lowest-numbered room and the only exit is at the highest-numbered room. Each passage has a limit in the number of people that can pass through at a time. For two rooms numbered \textbf{x} and \textbf{y}, if \textbf{x} and \textbf{y} have a common factor greater than one, then there is a passage between \textbf{x} and \textbf{y}. The largest common factor \textbf{p} is the number of people per minute that can walk from \textbf{x} to \textbf{y}. Simultaneously, \textbf{p} people per minute can also be walking from \textbf{y} to \textbf{x}. The entrance, exit, and rooms can handle any number of people walking through at a time. People want to get through the maze as quickly as possible, so they do not wait around in the rooms. Here are illustrations of the two sample inputs. Boxes represent the numbered rooms, and each arrow is a passage labeled by the number of people per minute that can walk through it. \includegraphics{https://static.e-olymp.com/content/6f/6fe3080291fcc8cc27aa55bdfc92bfa8a672f178.jpg} \InputFile Input is a single maze description. The first line is an integer \textbf{2} ≤ \textbf{n} ≤ \textbf{1000} indicating the number of rooms in the maze. This is followed by \textbf{n} unique integers, one per line, which are the room numbers for the maze. Each room number is in the range \[\textbf{2}, \textbf{2}×\textbf{10^9}\]. \OutputFile Print the maximum number of people per minute that can enter the maze, assuming that people are exiting the maze at the same speed as people entering. No maze supports more than \textbf{10^9} people entering per minute.
Ліміт часу 5 секунд
Ліміт використання пам'яті 256 MiB
Вхідні дані #1
4
4
6
8
9
Вихідні дані #1
3
Джерело 2012 ACM-ICPC North American Qualification Contest