weird function

Let us define : F[1] = 1 F[i] = (aM[i] + bi + c) % 1000000007 for i > 1 where M[i] is the median of the array {F[1],F[2],…,F[i-1]}. The median of an array is the middle element of that array when it is sorted. If there are an even number of elements in the array, we choose the first of the middle two elements to be the median. Given a,b,c and n, calculate the sum F[1] + F[2] + … + F[n].

can u plz send me the solution to the above problem asap…thanking u in advance

luckybhy@gmail.com

+918985109088

Try to use two priority queue. It’s an SPOJ Question so i don’t know if it’s legal to post the solution.

1 Like

I’ve tried it with two priority queues, but it is showing time limit exceeded…

//