Killjee and non-co-prime subarray
Practice
4 (4 votes)
Mathematics
Medium
Greatest common divisor
Greatest common divisor
Problem
33% Success 725 Attempts 30 Points 0.5s Time Limit 256MB Memory 1024 KB Max Code

Killjee has a very easy problem for you. You need to find number of non-co-prime sub-arrays for a given array a containing n elements.

A sub-array of array a is called non-co-prime if gcd(\(a_l\),\(a_{l+1}\),_____,\(a_r\)) 1. Where sub-array contains elements \(a_l\),\(a_{l+1}\),_____,\(a_r\).

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

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

INPUT FORMAT
First line of input contains a single integer n, denoting number of elements in array a.

Next line contains n space separated integers, elements of array a.

OUTPUT FORMAT
output a single integer number of non-co-prime sub-arrays.

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:
Basic ProgrammingNumber theory
Points:30
11 votes
Tags:
MathematicsMediumGreatest common divisorNumber Theory
Points:30
1 votes
Tags:
GCDNumber TheoryC++Math