Solution (source code)

= Solution

If $p\mid n$, the <field> property forces $x=0$, giving exactly one solution. Otherwise, if $x_0$ is any solution, multiplication by $x_0$ is a <bijection> from the solutions of $z^k=1$ to those of $x^k=n$. Part (i) therefore gives
$$
\boxed{\begin{cases}1,&p\mid n,\\0\text{ or }\gcd(k,p-1),&p\nmid n.\end{cases}}
$$
The two possibilities in the second line distinguish an empty fiber from a <coset> of the <kernel> of the power <group homomorphism> on $\mathbb F_p^\times$.