Data Structures & AlgorithmsVery hardICPC regional · Codeforces Div2 C
Problem: The value of 3^(3^3) mod 7 is what?
- A. 6
- B. 1
- C. 4
- D. 3
Correct answer: A. 6
3 has order 6 mod 7 and 27 ≡ 3 (mod 6), so 3²⁷ ≡ 3³ = 27 ≡ 6. Reducing the exponent mod 7 instead gives 3⁶ ≡ 1, computing 3 · 27 = 81 gives 4, and 3 is just the reduced exponent.
More Coding Interview Problems questions
- Problem: A path graph has vertices 1–6 with edges between consecutive vertices. How many pairs of vertices are at distance exactly 2?
- Problem: Consider the directed graph with arcs 1→2, 2→3, 3→4, 4→2, 1→5. Starting from 1, how many distinct vertices are reachable…
- Problem: In the array [9, 2, 6, 4, 7, 1], what is the number of elements that are smaller than every element to their left (strict left…
- Problem: The number 2^10 − 1 has how many distinct prime factors?
- Problem: A text buffer contains "hello world". Each space is replaced by the three characters "%20" (URL-style encoding). What is the…
- Problem: The bitwise AND of all integers from 12 to 15 inclusive is computed. What is the result?