Data Structures & AlgorithmsHardCodeforces Div2 B · number theory
Problem: How many integers x in [1, 50] are perfect sixth powers (x = y^6 for an integer y)? Run the code.
Problem: How many integers x in [1, 50] are perfect sixth powers (x = y^6 for an integer y)? Run the code.
print(sum(1 for x in range(1, 51) if round(x ** (1 / 6)) ** 6 == x))What is printed?
- A. 2
- B. 1
- C. 0
- D. 3
Correct answer: B. 1
Only 1 = 1^6 lies in range, since 2^6 = 64 is already above 50. Confusing sixth powers with cubes (8, 27) gives a wrong count.
More Coding Interview Problems questions
- Problem: Merging ropes of lengths 2, 3, 4 costs the sum of the two lengths merged each time, always merging the two shortest. What is the…
- Problem: How many subsets (including the empty one) of {1, 2, 3, 4, 5} have a sum divisible by 4? Run the code. python print(sum(1 for m…
- Problem: What does the following print? It takes the maximum of every window of size 2 in [4, 2, 12, 11, -5]. python a = [4, 2, 12, 11…
- Problem: What is the sum of the number of 1-bits in the binary representations of 1, 2, ..., 20? Run the code. python…
- Problem: Which statement about shortest paths in a weighted directed acyclic graph (DAG) is correct?
- Problem: Which statement about Floyd-Warshall on a graph with V = 400 vertices and no negative cycles is correct?