Let $(G,\cdot)$ be a finite group with $\Bbb N \ni n\ge 2$ elements. Prove that if for every divisor $d$ of $n$ there is a unique subgroup of $G$ which has $d$ elements, then $(G,\cdot)$ is a cyclic group.
Solution : Consider the sets $M_d=\{a\in G| \operatorname{ord} a=d\}$. Any two of these sets are disjoint and they form a partition of $G$.
We have $M_d \neq \emptyset \iff \exists$ a cyclic subgroup of $G$ of order $d$. Let's denote this subgroup by $H_d$. According to the hypothesis, $H_d$ is the unique subgroup of order $d$ of $G$.
$\implies M_d=\{a \in G \mid \langle a\rangle=H_d\}$, so $|M_d|=\phi(d)$.
We have that $n=\sum\limits_{d|n}|M_d|=\sum\limits_{d|n}\phi(d)$, which is true, so there will exist a cyclic subgroup of $G$ of order $n$. Hence, $(G,\cdot)$ is cyclic.
I came up with this solution after I read the solution of a similar problem and I tried to use the same reasoning to solve this problem. I think that the reasoning itself is sound, but I feel that there may be a few issues with my solution. I am basically assuming that none of the sets $M_d$ is empty and I don't think that is correct. Intuitively, it is , because the sets $M_d$ form a partition of $G$ and if one of them is empty, then they no longer form a partition. But I don't think that it is necessary for them to form a partition, so one of them may as well be empty and, as a result, my reasoning is flawed.
A friend suggested that I should just change $|M_d|=\phi(d)$ to $|M_d|\le \phi(d)$(which is obviously true) and then I would have that $n=\sum\limits_{d|n}|M_d| \le \sum\limits_{d|n}\phi(d)=n$, which would imply that every set $M_d$ is not empty, so $H_d$ exists and the desired conclusion is reached. To me, this seems true, but I would like to know if it really is and if there are any other better ways to repair the flaw in my solution.
Edit: Is it possible that I may not actually be assuming that $M_d$ is non-empty? What I mean is : it is true that $M_d=\{a \in G \mid \langle a\rangle=H_d\}$(it is true because if there are to be elements of order $d$, then they will be a generator of that cyclic subgroup of order $d$).From here I get that $|M_d|=\phi(d)$, so since the sets $M_d$ form a partition I reach the equality $n=\sum\limits_{d|n}|M_d|=\sum\limits_{d|n}\phi(d)$, which is true, so from here I would get that every $M_d$ is non-empty and the conclusion would follow. Does this work?
As you said in edit and as was said in the comments, the issue is with saying that $|M_d|=\phi(d)$ because of $M_d$'s definition, but this holds if and only if $M_d\neq\emptyset$.
However, you gave all the keys of the proof. As you said, $G$ is the disjoint union of the $M_d$s, and $|M_d|=\phi(d)$ if and only if $M_d$ is non-empty. As your friend said, if one of the $M_d$ is empty, the cardinal of the union is strictly smaller than $\sum\limits_{d|n}\phi(d)=n$, but the union is $G$ itself! Contradiction.