Company: MediaNet_7july
Difficulty: medium
GOAT-master Pass-code Problem Description GOAT-master has been arrested and is being held in a high-tech prison. To escape he must disable every camera, and to do that he needs a pass-code P . The pass-code is the answer to the matrix puzzle below. Help him work it out. You are given a square matrix A of order N x N , with rows and columns numbered from 0 to N - 1 . A cell A[i][j] is either blocked , written as -1 , or open , in which case it holds a positive integer. All open cells hold distinct values. You may step from an open cell to an open cell that shares an edge with it (up, down, left or right). Blocked cells can never be entered or crossed. A cell A[x][y] is reachable from A[i][j] when some sequence of such steps leads from A[i][j] to A[x][y] ; every open cell is reachable from itself. For an open cell A[i][j] , its sed-value S[i][j] is the sum of the values of all open cells A[x][y] that satisfy both conditions: A[x][y] is a multiple of A[i][j] , and A[x][y] is not reachable