How many non-empty subsets of $1,2,3,\cdots,p-2,p-1$ have a sum which is divisible by $p$ that $p$ is an odd prime

combinatoricsdivisibilitynumber theory

I have to do a IMO training homework but there is a question that confusing me.

How many non-empty subsets of $1,2,3,\cdots,p-2,p-1$ have a sum which is divisible by $p$ that $p$ is an odd prime?

I have tried $p=3,5,7$ and the number of subsets is $1,3,9$ respectively. I have thought of if the answer is $3^\frac{p-3}{2}$, but I am pretty not sure. If anyone knows the answer or find the number of subsets when $p$ is other odd primes, please tell me. Thank you!

Best Answer

Consider, instead, subsets of $\{0,1,\ldots,p-1\}$. There will be twice as many subsets; and twice as many whose sum is a multiple of $p$ because you have the option of including $0$ in any subset.
Take any subset except the empty set and the full set. Call it $S_0=\{x_1,\ldots,x_k\}$. Note that $1\le k\le p-1$. There are $p$ sets $S_i=\{i+x_1,\ldots,i+x_k\}$ formed by adding the number $i$ to each element, as $i$ ranges from $0$ to $p-1$. This adds $ki$ to the sum, so the sums are all different $\pmod p$ because we have excluded the empty set and the full set.
So the $2^p-2$ subsets split up into $p$ equal groups. There are $(2^p-2)/p$ that are multiples of $p$.
Add back in the empty set and full set to give $2+(2^p-2)/p$. Pair up sets that include $0$ with sets that don't, and remove the sets that include $0$. That leaves $1+(2^{p-1}-1)/p$. Lastly, remove the empty set to leave $(2^{p-1}-1)/p$.

Related Question