|
|||
NecklacePeter bought a neklace with colored pearls to his sister- It is a magical necklace: the colors are changing at nights. The different colors are coded by positive numbers and if is the actual color of a pearl then its new color is where are the colors of the two neighbouring pearls, and is the integer part function. The changes are happening at once! According to the seller, after some nights the colors will be the same. Peter wants to know this (final) color () and the number of nights needed to achieve this state (). Help him to compute them! Input specificationIn the first line there is a number , the number of pearls on the necklace. In the next line there are space separated numbers , the actual colors of the pearls. Output specificationIn the first line the number nights , then in the next one the final color . Constraints
Sample input 1
Sample output 1
Sample input 2
Sample output 2
Sample input 3
Sample output 3
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |