Complex Integer Solutions
Time limit8sMemory limit512 MB
Given an integer polynomial of degree at most 10, find all Gaussian integer roots and print them sorted by real then imaginary part.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Brute force, Implementation
- Solved
- No attempts yet
Problem
Let , where each () is an integer constant and . Write a program that finds all complex integer solutions of . A complex integer is a complex number whose real and imaginary parts are both integers.
Input
The input consists of two lines. The first line contains , the degree of . The second line contains integers . The following are guaranteed: , , and .
Output
Print two lines. On the first line, print the number of complex integer solutions. On the second line, print the solutions separated by spaces. Count and print each solution exactly once even if it is a multiple root. Sort the solutions in ascending order of real part, then imaginary part, and print them in the following format: 0, -2, i, -3i, 2+i, 3-4i.