You need to implement the following functions for the class Fib:
void setBase(int, int);
int64_t operator[](int);
After setBase(x, y), the data structure, fib, should contain an infinite length sequence, { x, y, x + y, x + 2y, 2x + 3y, ... } and so on. Every term is the sum of the two terms before it, except for the first two terms.
Of course you won't be able to store an infinite length sequence, but you need to manage to respond with the k'th term of the sequence whenever fib[k] is invoked.
Q
OP_1
OP_2
...
OP_Q
Where Q is an integer representing the number of operations. Q lines follow.
OP_i is the i'th operation, and it may be one of the two following forms:
0 A B
1 K
Where "0 A B" will invoke fib.setBase(A, B), and "1 K" will invoke fib[K]. Note that the index is 0-based. The operations has to be accomplished in the order they are given.
1 <= Q <= 10^6
0 <= A, B <= 10^9
0 <= K <= 10^9
It is guaranteed that the result always fits in 64 bit signed integer.
It it guaranteed that the first operation always starts with "0".
For every operation that starts with "1", print the result in one line.