Polynomial sign
Tag(s):

## Easy-Medium, Linear Algebra, Mathematics

Problem
Editorial
Analytics

Consider a polynomial function $f(x)$ with integer coefficients: $a_0 + a_1 \cdot x + ... + a_n \cdot x^n$. Lets define $superBig = 10000^{10000^{10000}}$. Someone really wants to know $sgn(f(superBig))$ and $sgn(f(-superBig))$. Please, help him to find the sign of these values. Note that $a_n$ can be zero.

Input format

The first line contains single integer n ($0 \leq n \leq 3 \cdot 10^5$).

The second line contains $n+1$ space separated integers $a_i$ ($-10^{18} \leq a_i \leq 10^{18}$) - the coefficients of polynomial.

Output format

Print two space separated integers $sgn(f(superBig))$ and $sgn(f(-superBig))$.

Note that these values can be only 1, 0 or 1.

SAMPLE INPUT
1
-100 1

SAMPLE OUTPUT
1 -1

Explanation
• $sgn(f(superBig)) =sgn(superBig - 100) = 1$, $superBig - 100 > 0$
• $sgn(f(-superBig)) =sgn(-superBig - 100) = -1$, $-superBig - 100 < 0$
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 512 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in Challenge Name

October Circuits '17

OTHER PROBLEMS OF THIS CHALLENGE
• Algorithms > Sorting
• Algorithms > Graphs
• Math > Counting
• Algorithms > String Algorithms
• Data Structures > Advanced Data Structures
• Data Structures > Advanced Data Structures