Prime Query
You are given an array $A$ of length $N$. For the array $A$, a pair $(i, j) \: (1\le i\lt j \le N)$ is said to be *good* if both $(A_i + A_j)$ and $(A_i \cdot A_j)$ are [prime numbers](https://en.wikipedia.org/wiki/Prime_number). You are given $Q$ queries in the format: - $L$ $R$ $K$: Let $B$ denote the subarray $A[L, R]$. You are allowed to update **at most** $K$ elements of the array $B$ to a
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start