Data Structures & AlgorithmsHardGATE CS · TCS NQT

How many unordered pairs {x, y} of distinct integers from 1 to 20 have x + y divisible by 5?

  1. A. 76
  2. B. 38
  3. C. 48
  4. D. 32

Correct answer: B. 38

Residues mod 5 have four numbers each; valid pairs are (0,0): C(4,2) = 6, (1,4): 16 and (2,3): 16, total 38. Counting ordered pairs gives 76, using 4 × 4 for the (0,0) class gives 48, and forgetting that class gives 32.

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

Exams that ask this topic