N Div Tree

3.7

3 votes
Algorithms, Graphs, Hard
Problem

Given a tree having N nodes numbered from 1 to N, You have to find the number of paths (u,v) such that on path from u to v there should not exist any pair of nodes (a,b) such that a divides b.

Input Format:
First line consists of a single integer denoting N.
Following N1 lines consists of two space separated integers u,v denoting there is an edge between node numbered u and node numbered v.

Output Format:
Print the required answer.

Constraints:
1N105
1u,vN

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?