Time limit1sMemory limit1024 MB
Given an integer polynomial f, find a polynomial g with coefficients from -100 to 100 such that g(g(x)) = f(x), or report -1.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
A polynomial with integer coefficients, defined for all real , is given.
If a polynomial satisfies for all , then is called a square root of .
Determine whether has a square root in which every coefficient is an integer between and inclusive. If one exists, print any such .
Input
The first line contains the degree of .
The second line contains the coefficients of , separated by spaces.
Output
If a polynomial () satisfying the conditions exists, print on the first line. Then print in that order, separated by spaces, on the second line. If several answers exist, print any one of them.
If does not exist, print -1 on the first line.
Constraints
- ,