  Let $f\in\Bbb F_q[X_1,\dots,X_n]$ with $\deg f=d>0$ and let
$Z(f)=\{(x_1,\dots,x_n)\in \Bbb F_q^n: f(x_1,\dots,x_n)=0\}$. Ax's theorem
states that $|Z(f)|\equiv 0\pmod {q^{\lceil n/d\rceil-1}}$, that is,
$\nu_p(|Z(f)|)\ge m(\lceil n/d\rceil-1)$, where $p=\text{char}\,\Bbb F_q$,
$q=p^m$, and $\nu_p$ is the $p$-adic valuation. In this paper, we determine a
condition on the coefficients of $f$ that is necessary and sufficient for $f$
to meet Ax's bound, that is, $\nu_p(|Z(f)|)=m(\lceil n/d\rceil-1)$. Let
$R_q(d,n)$ denote the $q$-ary Reed-Muller code $\{f\in\Bbb F_q[X_1,\dots,X_n]:
\deg f\le d,\ \deg_{X_j}f\le q-1,\ 1\le j\le n\}$, and let $N_q(d,n;t)$ be the
number of codewords of $R_q(d,n)$ with weight divisible by $p^t$. As
applications of the aforementioned result, we find explicit formulas for
$N_q(d,n;t)$ in the following cases: (i) $q=2^m$, $n$ even, $d=n/2$, $t=m+1$;
(ii) $q=2$, $n/2\le d\le n-2$, $t=2$; (iii) $q=3^m$, $d=n$, $t=1$; (iv) $q=3$,
$n\le d\le 2n$, $t=1$.
