This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
This is the problem: | |
Given an undirected and connected graph of N vertices and N-1 edges. | |
The number written on the ith vertex is val[i]. The task is to count | |
the number of pairs(x,y) such that the following conditions are satisfied: | |
0 ≤ x < y ≤ N-1 | |
The GCD of the numbers written on the vertices on the simple path in the given graph from x to y should be divisible by K. | |
For Example: |