Company: Infosys_12july
Difficulty: medium
Question 2 Problem Description You are given a tree of N nodes, each node has a value A i written on it. The Parent of each node is denoted by the Par array, where Par[i] denotes the parent of the ith array. The node whose Parent is 0 is root node and node 0 does not exist. For some positive integer g, we call a pair of nodes (u, v) g disconnected if the following conditions hold: Both A u and A v are multiples of g. There is no path between u and v in the tree, such that all the values on this path are multiples of g. For some positive integer g, a set of nodes is considered g good if the following conditions hold: The set is not empty. All values of the nodes in the set are multiples of g. The nodes of the set are pairwise g disconnected. In other words, for every pair of nodes u,v in the set such that u is not equal to v, the pair (u,v) is g disconnected. Two sets of nodes are considered different if there is a node that is contained in one of the sets, but not both of them. For som