C) Love for GCD
Practice
3 (1 votes)
Easy
Math
Problem
90% Success 927 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

One day while going across the topic GCD Adi came across a very simple question.

You are given an array consisting of N integers.

You have to find the number of pairs in the array such that GCD(A[ i ],A[ j ]) <MIN(A[ i ],A[ j ])

INPUT

First line contains an integer N denoting the size of the array.

Next line contain N space separated integers dentoing the array.


OUTPUT

Find the number of pairs such that GCD(A[ i ],A[ j ]) <MIN(A[ i ],A[ j ]).


CONSTRAINT

\(2 \leq N \leq 10^{5}\)

\(0 \leq A[i] \leq 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:20
12 votes
Tags:
Greatest common divisorAlgorithmsGCDMathNumber Theory
Points:20
Tags:
ImplementationEasy
Points:20
7 votes
Tags:
MathematicsApprovedEasyGreatest common divisor
Editorial

No editorial available for this problem.