7. In the corners of a square courtyard stand four houses, in which hooligans who are friends with each other live. Starting from January 1, 2017, every day, two hooligans from neighboring houses would quarrel and remain in a quarrel forever. By January 1, 2018, for the first time, there was no one left to quarrel with. How many hooligans could there have been in total? Provide all possible variants and explain why there are no others.
Solution. Divide the hooligans into two gangs: each will unite hooligans from opposite houses. Let there be $X$ hooligans in one and $Y$ in the other. To make sure all necessary hooligans quarrel, $X \cdot Y$ quarrels are required, and this equals 365. This number has only two prime factors: 5 and 73. Therefore, there are exactly two factorizations of 365 into a product of two numbers:

$$
365=73 \cdot 5, \quad 365=365 \cdot 1
$$

we get the answer: there were either $73+5=78$ hooligans, or $365+1=366$.