Fomin D:

The hostess baked a pie for the guests. At the table, there can be either $p$ people or $q$ people ($p$ and $q$ are coprime). Into what minimum number of pieces (not necessarily equal) should the pie be cut in advance so that in any case it can be distributed equally?
Considering the pie as a long rectangle, we will divide it into $p$ equal pieces ($p-1$ cuts) and into $q$ equal pieces ($q-1$ cuts). Since the number of cuts is $p+q-2$, the number of pieces is $p+q-1$.

Consider an arbitrary partition of the pie with volume $p q$. Let the guests be the vertices of a graph (a total of $p+q$ vertices). For each piece, we draw an edge connecting the two guests who receive this piece during the first and second distribution. Consider one of the connected components. The sum of the "volumes" of its edges must be divisible by both $p$ and $q$, so it is equal to $p q$. Therefore, the graph is connected, and thus the number of its edges is at least $p+q-1$ (see problem $\underline{31098}$ a, b).

## Answer

Into $p+q-1$ pieces.