report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Maximum GCD - MarisaOJ: Marisa Online Judge

Maximum GCD

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ of $n$ integers. Find the maximum value of $GCD(A_i,A_j)$ with $1 \le i < j \le n$. ### Input - The first line contains an integer $n$. - The next line contains $n$ integers $A_i$. ### Output - Print the maximum value of $GCD(A_i,A_j)$. ### Constraints - $2 \le n \le 10^5$. - $1 \le A_i \le 10^6$. ### Example Input: ``` 4 3 6 5 2 ``` Output: ``` 3 ```
Basic number theory
Prime number 2
Sieve of Eratosthenes
Segmented sieve
Prime factors
Maximum GCD
Divisors counting
Largest common divisor
Nearest Element
Divisors counting 2
GCD and LCM
GGCD
Square root sum
Square number
Sum sum sum
Topic
Math
Rating 1000
Solution (1) Solution