← All problemsSign in

Product on the segment by modulo

CodeChefRating 2581Open on judge ↗

Given an array A of N integers and an integer P ( not necessarily prime ). You are required to answer Q queries, i-th query is described by two numbers Li, Ri, the answer to the query is the product of all numbers in array A from index Li to index Ri modulo P. You have to answer the queries in online mode, that is you can't know a query before you answer all queries that are before it. Input t

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start