Data Structures & AlgorithmsHardCAT · Codeforces Div2 B
What is the sum of all integers in [1, 50] that are either perfect squares or perfect cubes?
- A. 176
- B. 175
- C. 177
- D. 179
Correct answer: B. 175
Collect the squares 1, 4, 9, ..., 49 and the cubes 1, 8, 27; the number 1 is both and must be counted once.
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 greatest common divisor of 6, 24, 60, 120 and 210?
- How many trailing zeros does 50! have when written in base 12 (note 12 = 2^2 3)?
- How many integers x in [1, 1000] satisfy x ≡ 2 (mod 13) and x ≡ 5 (mod 17)?
- How many index pairs i < j in [1, 2, ..., 10] (the integers 1 to 10) have i j divisible by 4?
- Start with the stack [1]. Operations in order: DUP (push a copy of the top), ADD (pop two and push their sum), DUP, DUP, ADD, ADD. What is…
- Two queues hold [1, 3, 5] and [2, 4, 6]. The output takes one element from the first queue, then one from the second, alternately, until…