問題一覧 > 通常問題

No.979 Longest Divisor Sequence

レベル : / AI推定難易度 : 1250 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 202
作問者 : ngtkana / テスター : noshi91
お気に入りにしたユーザー ProblemId : 3491 / 自分の提出
問題文最終更新日: 2020-01-31 22:19:09
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 235 (順位表) の他の問題:

Problem Statement

You are given a sequence $A_0 \dots A_{N - 1}$ of length $N$.
Among its subsequences $ A_{i_0} \dots A_{i_{K - 1}}\ (0 \leq i_0 < \dots < i_{K - 1} < N) $ satisfying both of the following 2 conditions,

  • Each term divides the next term: $ A_{i_0} | A_{i_1} | \dots | A_{i_{K - 1}} $
  • It is strictly increasing: $A_{i_0} < A_{i_1} < \dots < A_{i_{K - 1}}$
find the length $K$ of the longest one.
Here, for integers $X, Y$, the notation $ X | Y $ means that $ Y $ is a multiple of $ X $.

(21:43 Corrected $a_i$ to $A_i$)

Input

$N$
$A_0 \dots A_{N - 1}$

The input consists of 2 lines in total and satisfies the following constraints.

  • All input values are integers
  • $1 \leq N \leq 3 \times 10 ^ 5$
  • $1 \leq A_i \leq 3 \times 10^5\ (0 \leq i < N)$

Output

Print on one line the length of the longest subsequence satisfying the conditions.

Sample

Sample 1
Input
5
2 4 6 1 8
Output
3

The subsequence $2, 4, 8$, corresponding to indices $ 0, 1, 4 $, is the longest.

Sample 2
Input
5
1 3 3 9 2
Output
3

$1, 3, 9$ is the longest.

Sample 3
Input
1
1
Output
1

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。