Submit | All submissions | Best solutions | Back to list |
FIBPOL - Fibonacci Polynomial |
Let F(n) be the nth member of the Fibonacci sequence:
F(0) = 0, F(1) = 1, F(n) = F(n-1)+F(n-2) (n > 1)
Consider the following Fibonacci polynomial:
A(x) = x F(1) + x2 F(2) + x3 F(3) + ... + xn F(n) + ... = sigma(n = 0 to infinity) xn F(n)
Amazingly,
A(1/2) = 1/2 + 1/22 + 2/23 + 3/24 + .... + F(n)/2n + ... = 2
In this problem, we only considering the non-negative-integer value of A(x). Here are some examples of A(x) for specific x.
x | A(x) |
---|---|
0 | 0 |
sqrt(2)-1 | 1 |
1/2 | 2 |
[sqrt(13)-2]/3 | 3 |
[sqrt(89)-5]/8 | 4 |
Find out if x is rational with the given value of A(x)
Input
The first line contains T, the number of test cases. The next T lines contains the value of A(x).
- 0 <= Ax <= 10^17
- 1 <= T <= 100000
Output
- 1 if the given Ax yields a rational x, 0 otherwise
Example
Input: 5 0 1 2 3 4 Output: 1 0 1 0 0
Added by: | Piyush Kumar |
Date: | 2015-09-04 |
Time limit: | 1s-3s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY SCM qobi |
Resource: | Project Euler |
hide comments
|
|||||
2016-06-10 14:48:44 [Rampage] Blue.Mary
Please check your test cases. |