C# Solution (using operators and some tricks)
Code\n\npublic class Solution\n{\n  public int MaxTrailingZeros(int[][] grid)\n  {\n    var m = grid.Length;\n    var n = grid[0].Length;\n    var z = new Zeros
# Code\n```\npublic class Solution\n{\n  public int MaxTrailingZeros(int[][] grid)\n  {\n    var m = grid.Length;\n    var n = grid[0].Length;\n    var z = new Zeros[m, n];\n    for (var i = 0; i < m; i++)\n    for (var j = 0; j < n; j++)\n      z[i, j] = new Zeros(grid[i][j]);\n    var rowSum = new Zeros[m, n];\n    var colSum = new Zeros[m, n];\n    for (var i = 0; i < m; i++)\n    {\n      rowSum[i, 0] = z[i, 0];\n      for (var j = 1; j < n; j++)\n        rowSum[i, j] = rowSum[i, j - 1] + z[i, j];\n    }\n    for (var j = 0; j < n; j++)\n    {\n      colSum[0, j] = z[0, j];\n      for (var i = 1; i < m; i++)\n        colSum[i, j] = colSum[i - 1, j] + z[i, j];\n    }\n    var result = 0;\n    for (var i = 0; i < m; i++)\n    for (var j = 0; j < n; j++)\n    {\n      result = Max(result,\n        rowSum[i, j] + colSum[i, j] - z[i, j],\n        rowSum[i, n - 1] - rowSum[i, j] + colSum[i, j],\n        rowSum[i, j] + colSum[m - 1, j] - colSum[i, j],\n        rowSum[i, n - 1] - rowSum[i, j] + colSum[m - 1, j] - colSum[i, j] + z[i, j]);\n    }\n    return result;\n  }\n\n  private static int Max(params int[] values) => values.Max();\n\n  private struct Zeros\n  {\n    private readonly int _twos;\n    private readonly int _fives;\n\n    private static int NumCount(int n, int x)\n    {\n      var count = 0;\n      while (n % x == 0)\n      {\n        count++;\n        n /= x;\n      }\n      return count;\n    }\n\n    public static Zeros operator +(Zeros x, Zeros y) => new(x._twos + y._twos, x._fives + y._fives);\n    public static Zeros operator -(Zeros x, Zeros y) => new(x._twos - y._twos, x._fives - y._fives);\n\n    public static implicit operator int(Zeros x) => Math.Min(x._twos, x._fives);\n\n    private Zeros(int twos, int fives)\n    {\n      _twos = twos;\n      _fives = fives;\n    }\n\n    public Zeros(int value)\n      : this(NumCount(value, 2), NumCount(value, 5))\n    {\n    }\n  }\n}\n```
['C#']