3. Let $p>3$ be a prime number. For an arbitrary set $S \subseteq \mathbb{Z}$ and $a \in \mathbb{Z}$, let

$$
S_{a}=\left\{x \in\{0,1, \ldots, p-1\} \mid(\exists s \in S) \quad x \equiv_{p} a \cdot s\right\}
$$

(a) How many sets $S \subseteq\{1,2, \ldots, p-1\}$ are there such that the sequence $S_{1}, S_{2}, \ldots, S_{p-1}$ contains exactly two distinct elements?

(b) Determine all possible values of the number $k \in \mathbb{N}$ for which there exists a set $S \subseteq\{1,2, \ldots, p-1\}$ such that the sequence $S_{1}, S_{2}, \ldots, S_{p-1}$ contains exactly $k$ distinct elements.

(Milan Basić, Miloš Milosavljević)
3. Let $g$ be a primitive root modulo $p$. The sets $S_{1}, S_{2}, \ldots, S_{p-1}$ are the sets $S_{1}, S_{g}, \ldots, S_{g p-2}$ in some order. The sequence $S_{1}, S_{g}, S_{g^{2}}, \ldots$ has a period of $p-1$, so its minimal period $d$ divides $p-1$. Moreover, the sets $S_{1}, S_{g}, \ldots, S_{g d-1}$ are mutually distinct (if $S_{g i}=S_{g j}$, then $S_{1}=S_{g|j-i|}$). Furthermore, all multiplications are modulo $p$.

(b) From the above, it follows that $k \mid p-1$. On the other hand, for $k \mid p-1$, we can take $S=\left\{1, g^{k}, g^{2 k}, \ldots\right\}$.

(a) The minimal period of the sequence $S_{1}, S_{g}, S_{g^{2}}, \ldots$ is 2, so $S_{0}=S_{2} \neq S_{1}$. This means that $x \in S \Rightarrow g^{2} x \in S$. If $a, g a \in S$, then by the above, all $g^{n} a\left(n \in \mathbb{N}_{0}\right)$ are in $S$, i.e., $S=\{1,2, \ldots, p-1\}$, which is not possible. Therefore, $x \in S \Rightarrow g x \notin S, g^{2} x \in S$. From this, it follows that $S$ is one of the sets $\left\{1, g^{2}, g^{4}, \ldots, g^{p-3}\right\}$ and $\left\{g, g^{3}, \ldots, g^{p-2}\right\}$, i.e., there are two such subsets.