All Tracks Algorithms Graphs Depth First Search Problem

The Tree
Tag(s):

Medium

Problem
Editorial
Analytics

Paheli and Bhoojo are Appro’s long lost friends . The Last time Appro met them was in class 10th science class. Appro sees them after 6 years today but they are very angry with her , so they punish her and ask her to calculate strength of the tree in their backyard.

Strength of a tree is defined as maximum sum of number of divisors of subset of nodes of a tree but there is one condition , if a node is included in this set, none of its children can be a part.

Please help Appro with this.

Note: The tree is rooted at 1.

Input:

The first line of input contains single integer $$N$$ denoting the number of nodes in the tree.

Next $$N-1$$ lines contains 2 space separated integers $$A$$ and $$B$$ denoting that there is an edge from node $$A$$ to node $$B$$.

Output:

Print the required answer.

Constraints:

$$ 1\le N \le 10^6 $$

$$ 1\le A,B \le N $$

SAMPLE INPUT
3
1 2
1 3
SAMPLE OUTPUT
4
Time Limit: 1.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++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications