Comment

avatar username

Yes your approach is right, to implement this here is a simple idea — for example there are 3 elements in array: suppose — a1 has prime factorisation p1^q1*p2^q2*p3^q3 a2 has prime factorisation p1^q4*p2^q5*p4^q6 a3 has prime factorisation p1^q1*p3^q7*p4^q8 (p1,p2,p3,p4 are primes and q1...q8 are constants) Now total count of each primes : cnt[p1] = q1+q1+q4, cnt[p2] = q2+q5, cnt[p3] = q3+q7, cnt[p4] = q6+q8 Now these total counts basically represent the counts of primes of prime factorisation(if hypothetically we have multiplied a1*a2*a3(generalized a1*a2..*an)) Now if each individual count % n == 0 this means we can equally divide this prime in n positions ..if not then not possible to divide equally.

For finding prime factorization there is simple function in GFG, and to store counts you can use map.

The actual rating of this user is 1473.

Original comment.

Statistics