[C++] Short Implementation (20 Lines)
```\nint maxTrailingZeros(vector>& A, int ans = -1) {\n        for (int rot = 0; rot < 4; rot++) {\n            int n = A.size(), m = A[0].size();\n            
```\nint maxTrailingZeros(vector<vector<int>>& A, int ans = -1) {\n        for (int rot = 0; rot < 4; rot++) {\n            int n = A.size(), m = A[0].size();\n            vector<vector<int>> col2(n, vector<int>(m)), col5(n, vector<int>(m));\n            auto B = A;\n            for (int i = 0; i < n; i++) {\n                for (int j = 0, row2 = 0, row5 = 0; j < m; j++) {\n                    int c2 = 0, c5 = 0;\n                    while (B[i][j] % 2 == 0) B[i][j] /= 2, c2++;\n                    while (B[i][j] % 5 == 0) B[i][j] /= 5, c5++;\n                    \n                    col2[i][j] = c2, col5[i][j] = c5; // column prefix sum\n                    if (i > 0) col2[i][j] += col2[i - 1][j], col5[i][j] += col5[i - 1][j];\n                    \n                    ans = max(ans, min(row2 + col2[i][j], row5 + col5[i][j]));\n                    row2 += c2, row5 += c5; // row prefix sum\n                }\n            }\n            // Rotate Grid 90 degree\n            vector<vector<int>> T(m, vector<int>(n));\n            for (int i = 0; i < n; i++) reverse(A[i].begin(), A[i].end());\n            for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) T[j][i] = A[i][j];\n            swap(A, T);\n        }\n        return ans;\n    }
[]