Data Structures & AlgorithmsHardGATE CS · ICPC regional
How many integers n with 2 <= n <= 200 are square-free (not divisible by the square of any integer greater than 1)?
- A. 123
- B. {C-4}
- C. 127
- D. 121
Correct answer: D. 121
A square-free number is one none of whose prime factors appear squared; test divisibility by d^2 for d from 2 to sqrt(n). Counting the non-square numbers instead gives a different answer.
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
- What is the sum of Euler's totient phi(i) for i = 1 to 10 (phi(i) counts the integers k in [1, i] with gcd(k, i) = 1)?
- How many integers x in [0, 20] satisfy x^3 ≡ x (mod 7)?
- The 3-row by 4-column matrix is filled row by row with 1 to 12. What is the 7th element when the matrix is read in clockwise spiral order…
- A sliding window of size 3 moves over the array [5, 1, 4, 2, 8, 7, 6]. For each window take its maximum and then take the minimum of those…
- What is the number of distinct values of a[i] XOR a[j] over all pairs i < j of the array [1, 2, 3, 4]?
- How many palindromic substrings does the string aabbaa contain (counted by position)?