Closest Prime
CodeChefOpen on judge ↗
Problem description. You are given an array $a$ (1 indexed)of size $n$. You have to process following operations on the array 1 $l$ $r$ : update elements of indices from $l$ to $r$ inclusive to difference of element and nearest strictly smaller prime (eg: 5 gets updated to 5-3=2). Also note that since 0,1,2 does not have primes below then even after update they remain the same. 2 $l$ $r$ : Sum
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