Multiple Subsequence
Time limit2.5sMemory limit256 MB
Given a sequence, find the longest subsequence where each element is a larger multiple of the previous one.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Sorting
- Solved
- No attempts yet
Problem
You are given a sequence of natural numbers. Find the length of the longest subsequence in which every element is a multiple of the element before it and strictly larger than it.
A subsequence is built by picking some elements of the original sequence without changing their order. A subsequence with one element always satisfies the condition, so the answer is never smaller than 1.
Input
The first line contains the length of the sequence ().
Each of the next lines contains one element of the sequence, in order. Every element is a natural number smaller than .
Output
Print the length of the longest subsequence that satisfies the condition on the first line.