How to prove this exercise?
Let $A$ be a $n \times n$ diagonal matrix with characterist polynominal
$$(x-c_1)^{d_1}...(x-c_k)^{d_k}$$
where $c_i$ are distinct. Let $V$ be the space of $n \times n$ matrixes $B$ such that $AB=BA$. Prove that dimension of $V$ is $d_{1}^{2}+...+d_{k}^{2}$.