UVa 10183 - How Many Fibs?

10183 - How many Fibs?

 * http://acm.uva.es/p/v101/10183.html

Summary
A pretty ordinary BigNum problem.

Explanation
Generate the Fibonacci sequence until the last number generated exceeds $$10^{100}$$ and store it an array. It ends up taking about 480 numbers.

Gotcha's
The first number input may be 0. Not that that the problem defines a fairly non-standard sequence, where the first two numbers in the sequence aren't both 1, but rather 1 and 2.

Optimizations
Since we never have to through more than 500 numbers, and the size of the numbers, about 100 digits, is near the size of the sequence itself, a linear search to two find the correct lower and upper indices in the sequence is sufficient to pass the time limit. However, a binary search will yield a lower time.

Input
0 1 1 1 10 100 1234567890 9876543210 0 0

Output
1 1 5 4