Internship Offer
CodeChefOpen on judge ↗
In one of the interviews for summer internships, the interviewer asked Raghul an interesting problem. He first gave Raghul a weighted tree with $n$ vertices and an integer $m$. He then asked him $q$ questions, wherein each question was a pair $a,b$. The answer to each question was the **product** of the weights of the edges in the path from $a$ to $b$, modulo $m$. Raghul was able to easily answer
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