![在此处输入图片描述](https://i.stack.imgur.com/E69R4.png)
\documentclass{article}
\begin{document}
$\renewcommand\arraystretch{1.2}
\begin{array}{|c|c|c|c|c|c|}
\multicolumn{3}{c}{} & \multicolumn{3}{c}{B} \\
\cline{4-6}
\multicolumn{3}{c|}{} & 2 & 1 & 4 \\
\cline{4-6}
\multicolumn{3}{c|}{} & 5 & 0 & 1 \\
\cline{4-6}
\multicolumn{3}{c|}{} & 2 & 3 & 2 \\
\hline
3 & 1 & 2 & 3\cdot2+1\cdot5+2\cdot2 & 3\cdot1+1\cdot0+2\cdot3 & 3\cdot4+1\cdot1+2\cdot2\\
\hline
1 & 4 & 3 & & & \\
\hline
2 & 3 & 5 & & & \\
\hline
\multicolumn{3}{c}{A} & \multicolumn{3}{c}{AB} \\
\end{array}
$
\end{document}