Pagini recente » Diferente pentru problema/expresii2 intre reviziile 26 si 34 | Diferente pentru utilizator/radutadrian intre reviziile 4 si 3 | Diferente pentru problema/impartire intre reviziile 7 si 6 | Diferente pentru problema/piese intre reviziile 3 si 4 | Diferente pentru problema/sumtree intre reviziile 27 si 28
Nu exista diferente intre titluri.
Diferente intre continut:
The first line of the input will contain $N$ (1 ≤ $N$ ≤ 100000), the number of nodes. The second line will contain $N$ numbers, the $i-th$ number, representing the <tex>value_i</tex> (1 ≤ <tex>value_i</tex> ≤ 30000). Each of the next $N - 1$ lines will contain a pair of nodes $(u, v)$, each representing an edge of the tree.
For tests worth $20$ points (1 ≤ $N$ ≤ 1000)
For tests worth $20$ more points, <tex> value[i] = value[1] </tex> for $i = 1, 2,...n$
h2. Date de ieşire
The output will contain the sum of costs over all pairs of nodes $(u, v)$, such that $gcd(value[u], value[v]) > 1$
h2. Restricţii
For the first subtask (1 ≤ $N$ ≤ 1000)
For the second subtask, <tex> value[i] = value[1] </tex> for $i = 1, 2,...n$
h2. Exemplu
Nu exista diferente intre securitate.
Topicul de forum nu a fost schimbat.