Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 C
Problem: The number of trailing zeros of 500! written in base 6 (i.e., how many times 6 divides 500!) is what value?
- A. 247
- B. 494
- C. 98
- D. 239
Correct answer: A. 247
6 = 2 × 3, so the exponent of 6 in 500! is min(v₂, v₃) = v₃ = 166 + 55 + 18 + 6 + 2 = 247. Taking v₂ gives 494, applying Legendre's formula to 6 as if it were prime gives 83 + 13 + 2 = 98, and stopping v₃ after the 27-term gives 239.
More Coding Interview Problems questions
- Problem: A 5×5 grid has 1s and 0s: 11000 / 11011 / 00100 / 01100 / 10001 (rows top to bottom). You may flip exactly one 0 into a 1. What…
- Problem: A DAG with vertices 0–5 has weighted edges 0→1 (2), 0→2 (1), 1→3 (2), 2→3 (3), 2→4 (1), 3→5 (1), 4→5 (5). How many distinct…
- Problem: An undirected connected graph has 9 vertices and 13 edges. What is the cyclomatic number (the number of independent cycles…
- Problem: An undirected graph on 7 vertices (0–6) has degrees 0:3, 1:2, 2:4, 3:1, 4:2, 5:3, 6:1. How many vertices have odd degree? (Such a…
- Problem: Vertices 0–5 with undirected edges 0-1, 1-2, 2-0, 2-3, 3-4, 4-5, 5-3. How many articulation points (cut vertices, whose removal…
- Problem: Using a min-heap, the stream 9, 4, 7, 1, 8, 2, 6, 3, 5 is processed as follows: after each insertion, pop the minimum if the heap…