FACTOR TREE DOUBT

can anybody tell me why this code of mine doesn’t even pass subtask1
https://www.codechef.com/viewsolution/31745347

You’re calculating (Number of Factors of (Happiness Quotient % MOD)). You need to calculate ((Number of Factors of Happiness Quotient) % MOD) instead. This was mentioned in one of the comments.

1 Like

oh,got it…thank you so much…BTW,thankyou for setting such a nice question,it’ll help me to learn MO’s algorithm

2 Likes

You can check out my video solution here : Factor Tree - Mo's algorithm on Trees | Codechef April Long Challenge 2020 - YouTube
I show how to apply mo’s on trees.

2 Likes

Appreciate your efforts,bud!

1 Like

Why can’t we use segment trees on the euler path array to answer queries?

1 Like

What will you store in segment tree?

A strutcture containing ll ans (answer to query L,R) and a vector< pair> , containing <factor, its contribution> to the answer.

https://www.codechef.com/viewsolution/31685851
what is wrong in this?