Data Structures & AlgorithmsModerateCodeforces Div2 B · ICPC regional warm-up
Problem: How many prime numbers are there that are less than or equal to 10^6?
- A. 78512
- B. 77777
- C. 78498
- D. 79001
Correct answer: C. 78498
Pi(10^6) = 78498, a standard value obtained from a sieve of Eratosthenes. Quick estimates such as x / ln x give about 72,000, which is the wrong magnitude for a contest bound check.
More Coding Interview Problems questions
- Problem: Let phi(k) be Euler's totient (the count of integers g in [1, k] with gcd(g, k) = 1). What is phi(1) + phi(2) + ... + phi(10)?
- Problem: Count the integers x with 1 <= x <= 1000 whose decimal digits sum to exactly 10.
- Problem: Modulo the prime p = 998244353, which value is the multiplicative inverse of 2, i.e. the x in [0, p) with 2x ≡ 1 (mod p)?
- Problem: A product of 11 matrices A1 A2 ... A11 is evaluated by choosing a full parenthesisation. How many different parenthesisations are…
- Problem: n = 10 people stand in a circle and every 3rd person is removed until one remains (counting starts at person 1 and the removed…
- Problem: Compute F(100) mod 1000 where F(0) = 0, F(1) = 1 and F(n) = F(n-1) + F(n-2). python def mul(A, B, m): return [[sum(A[i][k]…