Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 C
Problem: Starting with the number 100, subtract the square of the smallest prime factor of the current number each step (the number is always at least 2) until the number becomes 1 or less. How many steps are needed?
- A. 4
- B. 50
- C. 25
- D. 10
Correct answer: C. 25
100 and every later value are even, so each step subtracts 2² = 4: 100 → 96 → … → 0 in 25 steps. Using the largest prime factor gives 4 steps, subtracting 2 instead of 4 gives 50, and √100 = 10 is a guess.
More Coding Interview Problems questions
- Problem: The string "xyzxyzxyz" is split into 3 equal blocks of length 3. The blocks are compared: how many pairs of blocks (i < j) are…
- Problem: From the list of integers [10, 15, 20, 25, 30], remove the elements that are divisible by 4 or by 6 (the rest remain in order)…
- Problem: The number 1729 is written in base 10. What is the sum of its digits in base 12, given as the digit sum of 1729 written in base 12?
- Problem: A sorted list has values 3, 7, 7, 9, 12, 12, 12, 15. How many distinct values lie within the range [7, 12] inclusive?
- Problem: On a 3×3 grid, each cell is labelled with its row times column (1-indexed). The number of cells whose label is a perfect square…
- Problem: How many integers in [1, 100] have exactly 3 divisors? Run the code. python print(sum(1 for x in range(1, 101) if sum(1 for d in…