For problem statement at 1000-1999/1000-1099/1060-1069/1060/problemF.txt this is a correct solution, but verifier at 1000-1999/1000-1099/1060-1069/1060/verifierF.go ends with All tests passed can you fix the verifier? package main
import (
"fmt"
)
type Poly []float64
func mul(a, b Poly) Poly {
res := make(Poly, len(a)+len(b)-1)
for i := range a {
for j := range b {
res[i+j] += a[i] * b[j]
}
}
return res
}
func g(p Poly) Poly {
res := make(Poly, len(p)+1)
sum := 0.0
for i := range p {
term := p[i] / float64(i+1)
sum += term / 2.0
res[i+1] = p[i] * float64(2*i+1) / float64(2*i+2)
}
res[0] = sum
return res
}
func dfs(u, p int, adj [][]int) Poly {
res := Poly{1.0}
for _, v := range adj[u] {
if v != p {
childPoly := dfs(v, u, adj)
res = mul(res, g(childPoly))
}
}
return res
}
func main() {
var n int
if _, err := fmt.Scan(&n); err != nil {
return
}
adj := make([][]int, n+1)
for i := 0; i < n-1; i++ {
var u, v int
fmt.Scan(&u, &v)
adj[u] = append(adj[u], v)
adj[v] = append(adj[v], u)
}
for i := 1; i <= n; i++ {
poly := dfs(i, 0, adj)
fmt.Printf("%.10f", poly[0])
if i < n {
fmt.Print(" ")
}
}
fmt.Println()
}