#C1578. Maximum Tower Height
Maximum Tower Height
Maximum Tower Height
Given an array of positive integers representing box labels, determine the maximum height of a tower that can be constructed. A box can be placed on top of another if its label is divisible by the label of the box below it. In other words, you need to find the longest chain of boxes \(a_1, a_2, \ldots, a_k\) such that for every \(1 \leq i < k\), \(a_{i+1}\) is divisible by \(a_i\).
This problem challenges you to compute the length of the longest such chain after sorting the provided box labels in ascending order.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains an integer \(n\), the number of boxes.
- The second line contains \(n\) space-separated positive integers representing the labels on the boxes.
outputFormat
Output to standard output a single integer representing the maximum height of the tower (i.e., the length of the longest valid chain of boxes where each box's label divides the next box's label).
## sample6
1 3 6 2 4 12
4