Need Help in Codigo

Can Anyone please explain the approaches/solutions to the last two problems of codigo

In Wifi Password you have to think about changing the sum to GP sum.

In Happy sequence first change the nodes value i.e A[u]+=A[parent[u]] ,where parent[u] is node of parent of u,then use concept of segment tree on rooted tree and merge sort tree.