### Instruction:
Let $G$ be the set of polynomials of the form $$ P(z)=z^n+c_{n-1}z^{n-1}+\cdots+c_2z^2+c_1z+50, $$where $ c_1,c_2,\dots, c_{n-1} $ are integers and $P(z)$ has distinct roots of the form $a+ib$ with $a$ and $b$ integers. How many polynomials are in $G$?

### Response:

Since the coefficients of the polynomial are real numbers, any nonreal roots must come in conjugate pairs.  Thus, when we factor $P(z)$ over the integers, each factor is either of the form $z - c,$ where $c$ is an integer, or
\[(z - a - bi)(z - a + bi) = z^2 - 2az + a^2 + b^2,\]where $a$ and $b$ are integers, and $b \neq 0.$  Furthermore, the product of the constant terms must be 50, so for each linear factor, $c$ divides 50, and for each quadratic factor, $a^2 + b^2$ divides 50.  We call these linear and quadratic factors basic factors.  For each divisor $d$ of 50, so $d \in \{1, 2, 5, 10, 25, 50\},$ let $B_d$ be the set of basic factors where the constant term is $\pm d.$

For $d = 1,$ any basic quadratic factor must satisfy
\[a^2 + b^2 = 1.\]The only solution is $(a,b) = (0, \pm 1),$ which leads to the quadratic factor $z^2 + 1.$  We also have the linear factors $z \pm 1.$  Hence, $|B_1| = 3.$

For $d = 2,$ any basic quadratic factor must satisfy
\[a^2 + b^2 = 2.\]The solutions are $(a,b) = (\pm 1, \pm 1),$ which leads to the quadratic factors $z^2 - 2z + 2$ and $z^2 + 2z + 2.$  We also have the linear factors $z \pm 2.$  Hence, $|B_2| = 4.$

For $d = 5,$ the solutions to
\[a^2 + b^2 = 5\]are $(a,b) = (\pm 1, \pm 2)$ and $(\pm 2, \pm 1),$ so $|B_5| = 6.$

For $d = 10,$ the solutions to
\[a^2 + b^2 = 10\]are $(a,b) = (\pm 1, \pm 3)$ and $(\pm 3, \pm 1),$ so $|B_{10}| = 6.$

For $d = 25,$ the solutions to
\[a^2 + b^2 = 25\]are $(a,b) = (\pm 3, \pm 4),$ $(\pm 4, \pm 3),$ and $(0, \pm 5),$ so $|B_{25}| = 7.$

For $d = 50,$ the solutions to
\[a^2 + b^2 = 50\]are $(a,b) = (\pm 1, \pm 7),$ $(\pm 5, \pm 5),$ and $(\pm 7, \pm 1),$ so $|B_{50}| = 8.$

Now, consider the factors of $P(z)$ which belong in $B_d,$ where $d > 1.$  We have the following cases:

$\bullet$ There is one factor in $B_{50}.$

$\bullet$ There is one factor in $B_2,$ and one factor in $B_{25}.$

$\bullet$ There is one factor in $B_5,$ and one factor in $B_{10}.$

$\bullet$ There is one factors in $B_2,$ and two factors in $B_5.$

Case 1: There is one factor in $B_{50}.$

There are 8 ways to choose the factor in $B_{50}.$

Case 2: There is one factor in $B_2,$ and one factor in $B_{25}.$

There are 4 ways to choose the factor in $B_2,$ and 7 ways to choose the factor in $B_{25}.$

Case 3: There is one factor in $B_5,$ and one factor in $B_{10}.$

There are 6 ways to choose the factor in $B_5,$ and 6 ways to choose the factor in $B_{10}.$

Case 4: There is one factors in $B_2,$ and two factors in $B_5.$

There are 4 ways to choose the factor in $B_2,$ and $\binom{6}{2}$ ways to choose the two factors in $B_5.$

Hence, there are
\[8 + 4 \cdot 7 + 6 \cdot 6 + 4 \binom{6}{2} = 132\]ways to choose the factors in $B_d,$ where $d > 1.$

After we have chosen these factors, we can include $z + 1$ or $z^2 + 1$ arbitrarily.  Finally, the constant coefficient is either 50 or $-50$ at this point.  If the coefficient is 50, then we cannot include $z - 1.$  If the constant coefficient is $-50,$ then we must include $z - 1.$  Thus, whether we include $z - 1$ or not is uniquely determined.

Therefore, the total number of polynomials in $G$ is $132 \cdot 2^2 = 528.$