Data Structures & AlgorithmsVery hardGATE CS · ICPC regional
How many unordered pairs {a, b} with a < b and 1 <= a, b <= 30 have a * b a perfect square?
- A. 19
- B. 20
- C. 21
- D. 23
Correct answer: A. 19
A product is a square exactly when the square-free parts of a and b coincide. Grouping the numbers by square-free part counts the pairs directly.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- An array is [1, 2, 1, 2, 1, 2] (indices 0 to 5). How many pairs of even-indexed positions i < j hold equal values?
- What is the sum of all proper divisors of 220 (divisors less than 220)?
- How many integers in [1, 100] have an odd number of positive divisors?
- What is the last digit of 3^2024?
- How many strings of length 4 over the alphabet {0, 1, 2} have no two adjacent characters equal?
- What is the Z-function value sum over positions i = 1 to n-1 of the string abababab?