Time limit
2s
Memory limit
128 MB
The Fibonacci numbers are defined as follows.
F(n):=⎩⎨⎧0 1 F(n−1)+F(n−2)if n=0;if n=1;if n>1.
This definition is normally used for nonnegative integers (n). We can extend it to negative indices by requiring the recurrence (F(n)=F(n-1)+F(n-2)) to keep holding even when (n \le 1). For example, when (n=1), the equality (F(1)=F(0)+F(-1)) must hold, so (F(-1)=1).
Given an integer (n), determine the sign and absolute value of (F(n)).
The first line contains an integer (n). It satisfies (|n| \le 1,000,000).
On the first line, print 1 if (F(n)) is positive, 0 if it is zero, and -1 if it is negative.
On the second line, print (|F(n)|) modulo (1,000,000,000).