only one query is processing i.e the output is not coming .code is free of errors
ide: https://ide.codingblocks.com/s/189818
Fibonacci meets gcd
@Vishal123 you are calculating Fib number in O(n) that will result in time out as the n can be very large.
Also this question utilizes a mathematical property:
GCD(Fib(A),Fib(B))=Fib(GCD(A,B))
So we need to form a seg tree on the array (not on Fibonacci number)
After number calculation we will need to use matrix exponentiation to get Fib number.
You can refer to this code
output is getting wrong .
@Vishal123 you are returning INT_MAX when the query goes out of range, and then you are using inbuilt gcd function because of which you will get wrong answer (suppose left is INT_MAX right is some number x, using inbuilt GCD on both might result in some other number y which would be wrong to store)
Use custom GCD function and in that keep a check on situation when one number passed is INT_MAX. or can return -1 when we go out of range but still we will need to create a custom GCD function.