Geometric sequence
Practice
5 (4 votes)
Basic programming
Basics of implementation
Easy
Implementation
Problem
84% Success 2468 Attempts 30 Points 3s Time Limit 256MB Memory 1024 KB Max Code

Given a sequence \(a_1{\dots}a_n\).
You need to find a subsequence \(a_{b_1},a_{b_2},\dots,a_{b_m}(b_1< b_2<\dots<b_m)\) and an integer k which satifies \(a_{b_{i+1}}=k\cdot a_{b_i}\) for all \(1\le i<m\).
Your goal is to maximize \(m\).

Input

First line contains an integer \(n\).

Second line contains \(n\) integers, representing the sequence \(a_1{\dots}a_n\).

Output

An integer representing the maximum value of \(m\).

Constraints

\(1\le n\le 10^5\)

\(-10^5\le a_i\le 10^5\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
17 votes
Tags:
EasyImplementationMathProbabilityStatistics
Points:30
60 votes
Tags:
Easy
Points:30
42 votes
Tags:
Easy