Pregunta

I recently faced this problem in a programming contest: Given 3 square matrices N x N of size N up to 1000. All elements in 3 matrices are from 0 to 9. Check if matrix A x B equals to C, mod 10. In other words, return the result of expression (A x B) mod 10 == C.

For example:

$\qquad A = \begin{bmatrix} 0 & 5 & 8 \\ 1 & 4 & 9 \\ 2 & 3 & 3 \end{bmatrix}\qquad B = \begin{bmatrix} 3 & 5 & 0 \\ 1 & 2 & 6 \\ 3 & 7 & 0 \end{bmatrix}\qquad C = \begin{bmatrix} 9 & 6 & 0 \\ 4 & 6 & 4 \\ 8 & 7 & 8 \end{bmatrix}$

return: TRUE

If

$\qquad C = \begin{bmatrix} 1 & 6 & 0 \\ 4 & 6 & 4 \\ 8 & 7 & 8 \end{bmatrix}$

return: FALSE, since the element C(1, 1) must be 9.

Time limit is 1s, pretty strict. Please gives me some idea how to solve the problem efficiently; is it possible time $O(N^2)$?

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a cs.stackexchange
scroll top