|
|||
Longest
In a box, Peter has some ticket, each with a number written on it. He finds the following game interesting: First, he selects a ticket from the box and puts it on the table. Then he tries to find a number in the box that has some common prime factor with the last number on the table. If it is possible, then he puts it next to the last number, and tries again. If he fails to select an appropriate number, the game is over. He wants to know the length of longest possible number sequence, that can be selected from the box according to the rules. Help him to compute this maximal length! For example, if his tickets are: Input specificationThe number of tickets in the first line, then the space separated list of tickets in the next one. Output specificationA single line with the maximal possible length . Constraints
Sample input 1
Sample output 1
Sample input 2
Sample output 2
Sample input 3
Sample output 3
Sample input 4
Sample output 4
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |