Data Structures & AlgorithmsVery hardCodeforces Div2 D · ICPC regional

How many non-empty subsets of [4, 6, 9, 10, 15] (chosen by position) have a greatest common divisor equal to 1?

  1. A. 17
  2. B. 20
  3. C. 15
  4. D. 31

Correct answer: A. 17

Enumerate subsets (or count with Möbius inversion over divisors): a subset's gcd is the greatest common divisor of its members, and most subsets of these values share a factor. Counting all non-empty subsets ignores the gcd condition.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic