Polynomial sign

4

35 votes
Linear Algebra, Easy-Medium, Mathematics
Problem

Consider a polynomial function f(x) with integer coefficients: a0+a1x+...+anxn. Lets define superBig=100001000010000. Someone really wants to know sgn(f(superBig)) and sgn(f(superBig)). Please, help him to find the sign of these values. Note that an can be zero.

Read more about sgn function on https://en.wikipedia.org/wiki/Sign_function.

Input format

The first line contains single integer n (0n3105).

The second line contains n+1 space separated integers ai (1018ai1018) - 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.

Time Limit: 1
Memory Limit: 512
Source Limit:
Explanation
  • sgn(f(superBig))=sgn(superBig100)=1, superBig100>0
  • sgn(f(superBig))=sgn(superBig100)=1, superBig100<0
Editor Image

?