luogu#P4598. [HEOI2012] Akai 的数学作业
[HEOI2012] Akai 的数学作业
Background
Here lies the vast universe. Here flows the mighty Milky Way. Here is the one-and-only Solar System. Here is the blue Earth. Here, right here, is the fertile Chinese mainland. Here is the magical land of Hebei. Here is the beautiful city of Tangshan. Here is the mythical Tangshan No. 1 High School. Here is the classroom where Akai once studied.
Problem Description
On the blackboard remains a piece of math homework Akai once did. It is actually not a very difficult problem:
"Given a univariate polynomial equation of degree :
Find all rational solutions of this equation."
Akai still vividly remembers the nights he stayed up solving it. He even remembers how much scrap paper he wasted. But he just can’t recall the final answers. Can you help him?
Input Format
The first line contains an integer . The second line contains integers, representing to .
Output Format
Output an integer on the first line, the number of rational solutions. Then output lines, each containing one solution. Each solution must be printed as a fraction in lowest terms, with a positive denominator. If a solution is an integer, output the integer directly. Equivalent solutions should be output only once. Output all solutions in increasing order.
3
-24 14 29 6
3
-4
-3/2
2/3
Hint
- For 30% of the testdata, .
- For 100% of the testdata, , , .
HEOI 2012 Day 1 Task 1.
Translated by ChatGPT 5