Alternating LG Queries
You are given an array $A$ consisting of $N$ integers. You have to answer $Q$ queries of the following two types: - $1$ $L$ $R$ $(R > L)$ which asks you to find $\gcd(A_L, lcm(A_{L + 1}, \gcd(A_{L + 2}, ... , ((R - L) \bmod 2 == 1 ? $ $\gcd(A_{R - 1}, A_{R}) : lcm(A_{R - 1}, A_{R}))\ldots)))$. - $2$ $L$ $R$ $(R > L)$ which asks you to find the same as above but $lcm$ swapped with $\gcd$ and vice
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