Need help with the following problem :
Given an array of n integers. Count the number subsequence whose product is divisible by k. Return answer modulo 1E9 + 7.
1 <= n <= 1E5 1 <= k < 1E9 1 <= a[i] <= 1E9
I think idea is use to prime factorization but I am not able to get it completely. Is there any concept that I must learn??
https://codeforces.net/problemset/problem/577/B you can look this problems editorial I think this the same problem which you described ( I hope you upvote :) )
Thanks for the suggestion but these two are different problems
I recommend approaching this problem using the two-pointer technique. Here are some key insights to consider:
[l,r]
that is divisible by K, then both[l, r+1]
and[l-1, r]
should also be divisible by K.a[i] = K for all i from 1 to n
. Determine what that number is.I hope this information is helpful!