My approach, Find the diameter, applying a dfs with root = one leaf of the diameter. dfs(root,root,1)

ans[u] = 1(1 <= u <= n)

dfs(u,pu,cnt):

____ans[u] *= (all prime divisor of cnt) // for cnt = 12, I’ll multiply 2 * 3 to ans[u]

____for x in a[u]:

________dfs(x,u,cnt + 1)

Reason to do this, by this 2 will occur in every two nodes in a path, 3 will occur in every three nodes in a path and so on. (5,7,11,…)

I got WA, can anyone suggest where I went wrong?

My solution link: https://www.codechef.com/viewsolution/35811315

PS: ignore the rec function, that’s a stupidfunction I made