[Solution] Electrical Efficiency Codeforces Solution
In the country of Dengkleknesia, there are factories numbered from to . Factory has an electrical coefficient of . There are also power lines with the -th power line connecting factory and factory . It can be guaranteed that each factory in Dengkleknesia is connected to all other factories in Dengkleknesia through one or more power lines. In other words, the collection of factories forms a tree. Each pair of different factories in Dengkleknesia can use one or more existing power lines to transfer electricity to each other. However, each power line needs to be turned on first so that electricity can pass through it.
Define as the minimum number of power lines that need to be turned on so that factory can make electrical transfers to factory and factory . Also define as the number of distinct prime factors of .
To measure the electrical efficiency, you must find the sum of for all combinations of such that . Because the answer can be very large, you just need to output the answer modulo .
Note: is the greatest common divisor of , , and , which is the biggest integer that simultaneously divides , , and .
The first line contains a single integer () — the number of factories in Dengkleknesia.
The second line contains integers () — the electrical coefficients of the factories.
The -th of the next lines contains two integers and () — a power line that connects cities and . The collection of factories forms a tree.
An integer representing the sum of for all combinations of such that , modulo
No comments:
Post a Comment