Company: MediaNet_23july
Difficulty: medium
Help Your Master 2 Problem Description GOAT-master got arrested in a police chase. He is trying to escape the high-tech prison he is held captive in. He needs a pass-code for disabling all the cameras in order to escape. Pass-code is the solution of matrix problem given below. Help him finding the pass-code. You are given a matrix of order N×N. Each cell in a matrix has a value A[i][j] (0≤i,j<N) which is either positive or equal to -1 (representing blocked cell). Cells which are not blocked have distinct values. You can traverse from a cell in any direction (up, down, left or right), if there is no blockage. For any cell A[i][j], sed-value S[i][j] is defined as sum of values of cells A[x][y] which are multiple of A[i][j], but not reachable from A[i][j]. For blocked cells, sed-value is -1. Pass-code P is sum of sed-values of all the cells, modulo 1000000007. Input Format: First argument is a 2-D array of integers denoting the above matrix. Output Format: Return the sum of sed-values