𝐂++ 𝐏𝐫𝐞𝐟𝐢𝐱 𝐒𝐮𝐦 , 𝐅𝐚𝐜𝐭𝐨𝐫𝐬 𝐨𝐟 𝟐 𝐚𝐧𝐝 𝟓 ✅
\nclass Solution {\npublic:\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        int n=grid.size();\n        int m=grid[0].size();\n        int ans=0
```\nclass Solution {\npublic:\n    int maxTrailingZeros(vector<vector<int>>& grid) {\n        int n=grid.size();\n        int m=grid[0].size();\n        int ans=0;\n        vector<vector<pair<int,int>>> prorow(n,vector<pair<int,int>>(m,{0,0}));\n        vector<vector<pair<int,int>>> procol(n,vector<pair<int,int>>(m,{0,0}));\n        unordered_map<int,pair<int,int>> mp;\n        int c=0;\n        for(int i=1;i<=1000;i++){\n            int t=i;\n            int two=0,fiv=0;\n            while(t>0 && (t%2==0 || t%5==0)){\n                if(t%2==0){\n                    t/=2;\n                    two++;\n                }\n                else if(t%5==0){\n                    t/=5;\n                    fiv++;\n                }\n            }\n            mp[i]={two,fiv};\n        }\n        for(int i=0;i<n;i++){\n             int two=0,fiv=0;\n            for(int j=0;j<m;j++){\n                two+=mp[grid[i][j]].first;\n                fiv+=mp[grid[i][j]].second;\n                prorow[i][j]={two,fiv};\n            }\n        }\n          for(int i=0;i<m;i++){\n            int two=0,fiv=0;\n            for(int j=0;j<n;j++){\n                two+=mp[grid[j][i]].first;\n                fiv+=mp[grid[j][i]].second;\n                procol[j][i]={two,fiv};\n            }\n        }\n        for(int i=0;i<n;i++){\n            for(int j=0;j<m;j++){\n                int two=procol[i][j].first;\n                int fiv=procol[i][j].second;\n                int twoo=procol[n-1][j].first-two+mp[grid[i][j]].first;\n                int fivv=procol[n-1][j].second-fiv+mp[grid[i][j]].second;\n                \n                int a=two+prorow[i][j].first-mp[grid[i][j]].first;\n                int b=fiv+prorow[i][j].second-mp[grid[i][j]].second;\n                \n                int c=twoo+prorow[i][m-1].first-prorow[i][j].first;\n                int d=fivv+prorow[i][m-1].second-prorow[i][j].second;\n                \n                ans=max(ans,max(min(a,b),min(c,d)));\n                \n                a=two+(prorow[i][m-1].first-prorow[i][j].first);\n                b=fiv+(prorow[i][m-1].second-prorow[i][j].second);\n                \n                c=twoo+(prorow[i][j].first-mp[grid[i][j]].first);\n                d=fivv+(prorow[i][j].second-mp[grid[i][j]].second);\n                ans=max(ans,max(min(a,b),min(c,d)));\n            }\n        }\n        return ans;\n        \n    }\n};\n```
['C']