Polynomial Quine
Time limit0.5sMemory limit1024 MB
Given N, list all degree N-1 polynomials whose coefficients a_i lie in [0, N) and satisfy f(i) mod N = a_i for every i from 0 to N-1.
- Level
Medium7 of 10
- Topics
- Math, Number theory
- Solved
- No attempts yet
Problem
An integer-coefficient polynomial is called an -degree polynomial quine if it satisfies both of the following conditions.
- For every integer with , .
- For every integer with , .
Surprisingly, for , there are exactly polynomial quines of degree .
Given , write a program that finds all -degree polynomial quines.
Input
The first line contains one integer ().
Output
Print lines, one polynomial quine per line. Print the coefficients from down to , separated by single spaces. Do not print the same polynomial more than once.
Print the polynomials in ascending order of . If ties, sort by in ascending order, and so on. If through all tie, sort by in ascending order.