Help needed in this number theory problem

Revision en1, by chirag2505, 2022-06-10 14:27:23

Given an array of integers A of length N. For each index i, find number of indices j(j!=i) such that gcd(A[i],A[j])>1.

Constraints:
N<=1e5
1<=A[i]<=N

Example:

  1. A = [4,3,2,4] output = [2,0,2,2]

  2. A = [2,3,6,4,6,5] output = [3,2,4,3,4,0]

Tags number theory, gcd

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English chirag2505 2022-06-10 14:27:23 316 Initial revision (published)