ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Unsorted > задача:


50819 - Linked Numbers

Гость
• Вопросы к жюри (2)

Задачи раздела

• 50430 - ATM
• 50426 - Calculating Sales
• 50425 - Calculating Weekly Pay
• 50438 - Pattern with stars
• 50820 - Post Office
• 50810 - Print Office
• 50952 - Derby Tirana
• 50443 - Dajte Express
• 50819 - Linked Numbers
• 50519 - Image Filtering
• 50798 - Passing the course
• 50799 - OSHEE Electric Bill
• 50833 - Min of Odd Positions
• 50821 - Derivative of an array
• 50808 - Total Distance Traveled
• 50452 - Multiplication Table
• 50456 - nth Digit of a Number

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Linked Numbers

Assume that you are given the n numbers. Find the maximum length of number ordering such that the last digit of one number (an) is the same as the first digit of the next number (an+1). For example the following series complies the Linked Numbers property:

  12 235 514 
However the following series does not:
   12 235 415 
because second number 235 ends with 5, but the third number 415 starts with 4.

Question: You will be given n positive integer. By possible replacements, find the length of longest linked numbers.

Input specification
In the first line, you will be given a number: The number of numbers(n) 1 ≤ n ≤ 30. Then, in the following n lines, you will be given n integers which are between 0 and 12,000.

Output specification
Show the length of the longest linked list

Sample Input
4
235
12
317
514
Sample Output
3



Для отправки решений необходимо выполнить вход.

www.contester.ru