\(S=1^2+2^2+3^2+...+99^2\)
\(=1\left(2-1\right)+2\left(3-1\right)+3\left(4-1\right)+...+99\left(100-1\right)\)
\(=\left(1\cdot2+2\cdot3+3\cdot4+...+99\cdot100\right)-\left(1+2+3+...+99\right)\)
\(=\frac{99\cdot100\cdot101}{3}-\frac{99\cdot\left(99+1\right)}{2}\)
\(=333300-4950\)
\(=328350\)
\(M=1\cdot3+3\cdot5+5\cdot7+...+97\cdot99\)
\(=3+\frac{3\cdot5\cdot\left(7-1\right)+5\cdot7\cdot\left(9-3\right)+...+97\cdot99\cdot\left(101-95\right)}{6}\)
\(=3+\frac{3\cdot5\cdot7-1\cdot3\cdot5+5\cdot7\cdot9-3\cdot5\cdot7+...+97\cdot99\cdot101-95\cdot97\cdot99}{6}\)
\(=3+\frac{-\left(1\cdot3\cdot5\right)}{6}+\frac{3\cdot5\cdot7+5\cdot7\cdot9-3\cdot5\cdot7+...+97\cdot99\cdot101-95\cdot97\cdot99}{6}\)
\(=3+-\frac{15}{6}+\frac{97\cdot99\cdot101}{6}\)
\(=3+-2,5+161650,5\)
\(=161651\)