Solution (source code)

= Solution

By <matrix multiplication>, $D_{ij}=\sum_{k=1}^N B_{ik}C_{kj}$. A potentially nonzero term requires $k=i$ because $B$ is a <diagonal matrix>, and $k=j$ because $C$ is a <diagonal matrix>. For $i\ne j$ these requirements cannot both hold. Thus every summand is zero and \b[$D_{ij}=0$ whenever $i\ne j$].