Company: InMobi
Difficulty: easy
GCD Threshold Connected Components You are given n nodes numbered from 1 to n , and an integer g . The graph is undirected and is defined implicitly: for every pair of distinct nodes u and v , there is an edge between u and v if and only if gcd(u, v) == g where gcd denotes the greatest common divisor. No other edges exist, and there are no self-loops. Two nodes belong to the same connected component if one can be reached from the other by following zero or more edges. A node with no incident edge forms a connected component of size 1 on its own. Report two values for this graph: the number of connected components, and the number of nodes in the largest connected component. Input Format A single line containing two space-separated integers n and g . Output Format Print two lines. The first line contains the number of connected components of the graph. The second line contains the size of the largest connected component. Constraints 1 <= n <= 10^18 (inferred — the source states no