Good Subsequence Queries
Keep the smallest subset size for each gcd among multiples of p, then check whether gcd p fits in fewer than n elements.
Keep the smallest subset size for each gcd among multiples of p, then check whether gcd p fits in fewer than n elements.