Addition and Multiplication
You are given a one dimensional integer array A of length N. You need to maintain the array under Q queries of the following four types. Assume 1-based indexing and M = 109 + 7. Query 1 : 1 x y v This implies adding v to array A to all the indices from x to y, i.e., for (i = x; i Ai += v; Ai %= M; Query 2 : 2 x y v This implies multiplying the scalar v with the array A for all the indices from
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