JavaScript O(mn) DP
\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar maxTrailingZeros = function(grid) {\n    const rowC = grid.length, colC = grid[0].length\n    
```\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar maxTrailingZeros = function(grid) {\n    const rowC = grid.length, colC = grid[0].length\n    grid = grid.map(row => {\n        return row.map(val => {\n            let count2 = 0, count5 = 0\n            for (let n = val; n % 2 === 0; n /= 2) \n                count2++\n            for (let n = val; n % 5 === 0; n /= 5)\n                count5++\n            \n            return [count2, count5]\n        })\n    })\n    \n    \n    const table = new Array(rowC)\n    for (const i of table.keys()) {\n        const row = new Array(colC)\n        for (const j of row.keys())\n            row[j] = [\n                [0, 0],\n                [0, 0],\n                [0, 0],\n                [0, 0],\n            ]\n        \n        table[i] = row\n    }\n    \n    \n    for (let i = 0; i < rowC; i++) {\n        for (let j = 0; j < colC; j++) {\n            const cell = table[i][j], here = grid[i][j]\n            if (i === 0) {\n                cell[0] = [...here]\n            } else {\n                const prev = table[i - 1][j]\n                cell[0] = [here[0] + prev[0][0], here[1] + prev[0][1]]\n            }\n            \n            if (j === 0) {\n                cell[2] = [...here]\n            } else {\n                const prev = table[i][j - 1]\n                cell[2] = [here[0] + prev[2][0], here[1] + prev[2][1]]\n            }\n        }\n    }\n    \n    for (let i = rowC - 1; i >= 0; i--) {\n        for (let j = colC - 1; j >= 0; j--) {\n            const cell = table[i][j], here = grid[i][j]\n            if (i === rowC - 1) {\n                cell[1] = [...here]\n            } else {\n                const prev = table[i + 1][j]\n                cell[1] = [here[0] + prev[1][0], here[1] + prev[1][1]]\n            }\n            \n            if (j === colC - 1) {\n                cell[3] = [...here]\n            } else {\n                const prev = table[i][j + 1]\n                cell[3] = [here[0] + prev[3][0], here[1] + prev[3][1]]\n            }\n        }\n    }\n    \n    \n    let result = 0\n    for (const [i, row] of table.entries()) {\n        for (const [j, record] of row.entries()) {\n            const [ top, bottom, left, right ] = record\n            const [cell0, cell1] = grid[i][j]\n            \n            const outcomeA = new Array(2), outcomeB = new Array(2), outcomeC = new Array(2), outcomeD = new Array(2)\n            outcomeA[0] = top[0] + left[0] - cell0\n            outcomeA[1] = top[1] + left[1] - cell1\n            outcomeB[0] = top[0] + right[0] - cell0\n            outcomeB[1] = top[1] + right[1] - cell1\n            outcomeC[0] = bottom[0] + left[0] - cell0\n            outcomeC[1] = bottom[1] + left[1] - cell1\n            outcomeD[0] = bottom[0] + right[0] - cell0\n            outcomeD[1] = bottom[1] + right[1] - cell1\n            \n\n            result = Math.max(result, Math.min(...outcomeA), Math.min(...outcomeB), Math.min(...outcomeC), Math.min(...outcomeD))\n        }\n    }\n    \n    \n    return result\n};\n```
[]