Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

How many ordered pairs (a, b) with 1 <= a, b <= 6 satisfy a * b ≡ 1 (mod 7)?

  1. A. 6
  2. B. 4
  3. C. 36
  4. D. 12

Correct answer: A. 6

Every non-zero residue mod the prime 7 has exactly one inverse, so each a gives one b: 6 ordered pairs. Counting unordered pairs gives 4 ({1,1}, {2,4}, {3,5}, {6,6}), 36 counts all pairs and 12 double-counts each ordered pair.

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

Exams that ask this topic