Prime Distance On Tree
You are given a tree. If we select 2 distinct nodes uniformly at random, what's the probability that the distance between these 2 nodes is a prime number? ### Input The first line contains a number **N**: the number of nodes in this tree. The following **N**-1 lines contain pairs a[i] and b[i], which means there is an edge with length 1 between a[i] and b[i]. ### Output Output a real number deno
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start