FIB128 - 128bit-Fibonacci
This task is intended to help people to debug their codes and try speed experiments.
The task is the same as in some known problems, but with new constraints and speed goal.
The Fibonacci sequence is defined for any positive integer by : If N<2: Fib(N)=N, else Fib(N)=Fib(N-1)+Fib(N-2)
You have the task of being the fastest to compute Fib(N) mod M.
The input consists of 500,000 lines. In each the 500,000 lines there are two integers N, M. You don't need to read the whole input, only some lines to get some points. You should begin with one line, then 10, then 100, ...
For as many test cases you can, on a single line, print Fib(N) mod M.
Input: 5 4 5 5 5 6 [...] Output: 1 0 5
0 <= N <= 10^38 2 <= M <= 10^38
As in the example, if you can output the 3 first correct answers, your score will be 3 points. No need to solve all the input, the minimum is 1 ; every solver in any language will be able to check his FIB128-speed.
Paulo Roberto Santos de Sousa:
is there some 256 bit integer in c/c++ or I will have to implement bigint algorithm to solve the problem?
pro tip: use clang. gcc optimization heuristics is horribly broken.
Why TLE. I am using ************, and on IDEONE I am getting correct output.
Yep, my method is a dead end, 10^38 is too much!