$5 \cdot 23$ What restrictions should be placed on integers $p$ and $q$ so that
(1) For all $x \in Z$, the polynomial $P(x)=x^{2}+p x+q$ always takes even (odd) values?
(2) For all $x \in Z$, the polynomial $Q(x)=x^{3}+p x+q$ is always divisible by 3?
[Solution] (1) $P(0)=q$.
$$
P(1)=p+q+1 \text {. }
$$

For $x \in \mathbb{Z}$, $P(x)$ to be even $\Leftrightarrow P(0), P(1)$ are even $\Leftrightarrow q$ is even, $p$ is odd.

For $x \in \mathbb{Z}$, $P(x)$ to be odd $\Leftrightarrow P(0), P(1)$ are odd $\Leftrightarrow q$ is odd, $p$ is odd.
(2)
$$
\begin{array}{l}
Q(0)=q \\
Q(1)=1+p+q \\
Q(2)=8+2 p+q=2+2 p+q(\bmod 3)
\end{array}
$$

For $x \in \mathbb{Z}$, $Q(x)$ to be divisible by 3 $\Leftrightarrow 3|q, 3| 1+p+q$,
$$
3 \mid 2+2 p+q \Leftrightarrow q \equiv 0, p \equiv 2(\bmod 3) .
$$