Tree and Divisors
You are given a tree with $N$ vertices, rooted at vertex $1$. The $i$-th vertex of this tree has the integer $A_i$ written on it. For each vertex $u$ ($1 \leq u \leq N$), find the number of divisors of the product of all $A_v$ such that $v$ lies in the subtree of $u$. Formally, for each $u$: - Let $S_u$ denote the set of vertices that lie in the subtree of $u$ (including $u$). - Define $X_u = \p
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