lowe's 2nd round | yet another subset counting help needed|
Anonymous User
1222

Count the number of non-empty subsets S of A such that the product of numbers in that subset is of the form p1p2p3*...pk where p1p2p3*...pk are distinct prime numbers.
NOTES

  • prime numbers are those that are greater than 1 and have only two factors 1 and itself.
  • an array B is asubset of an array A if each element B is present in A and there are no repeated elements in B.
Example

assumptions:

  • N=4
  • A=[4,2,3,15]

Approach

  • for subset [2] :product=2
  • for subset [3] :product=3
  • for subset [2,3]product=6(2*3)
  • for subset [2,15]: product=30(235)
  • for subset [15] :product=15(3*5)

hence in total 5 subsets exist. thus answer is 5
Constraints
1<=N<=10000
1<=A[i]<=30

Comments (3)