All Tracks Algorithms Graphs Graph Representation Problem

N Div Tree
Tag(s):

Algorithms, Graph Theory, Hard

Problem
Editorial
Analytics

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 \(N-1\) 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:
\(1 \le N \le 10^5\)
\(1 \le u, v \le N\)

SAMPLE INPUT
2
1 2
SAMPLE OUTPUT
0
Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

HackerEarth Collegiate Cup - Mirror Round

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?