Solution (source code)

= Solution

Compactify $y^d=g(z)$ by adding the points over infinity. Since $d\mid n$, there are $d$ such points and they are unramified. Each of the $n$ simple finite roots is totally ramified with index $d$. Riemann-Hurwitz for the degree-$d$ map to $\mathbb P^1$ gives
$$
\boxed{2g-2=-2d+n(d-1),\qquad g=\frac{(d-1)(n-2)}2.}
$$