Data Structures & AlgorithmsHardCodeforces Div2 B · modular arithmetic
Problem: What is 7^222 mod 10? Run the code.
Problem: What is 7^222 mod 10? Run the code.
print(pow(7, 222, 10))What is printed?
- A. 7
- B. 3
- C. 1
- D. 9
Correct answer: D. 9
The last digit of powers of 7 cycles 7, 9, 3, 1 with period 4. Since 222 mod 4 = 2, the result is 9.
More Coding Interview Problems questions
- Problem: How many integers in [1, 500] are divisible by 4 or by 6? Run the code. python print(sum(1 for x in range(1, 501) if x % 4 == 0…
- Problem: How many ways can [1, 2, 3, 4] be split into two non-empty contiguous parts with equal sums? Run the code. python a = [1, 2, 3…
- Problem: Which algorithm finds all articulation points (cut vertices) of an undirected graph in O(V + E) time using DFS low-link values?
- Problem: Which statement about Kosaraju's algorithm for strongly connected components is correct?
- Problem: Which statement about the Edmonds-Karp maximum-flow algorithm (BFS augmenting paths) is correct?
- Problem: A road map has junctions 0–6 and two-way roads with lengths: 0-1 (4), 0-2 (1), 2-1 (2), 1-3 (5), 2-3 (8), 3-4 (3), 2-5 (10), 4-6…