What is the problem in my solution RGAME?

Problem :RGAME

My Solution:
https://codepaste.net/6ch44n
My code is not accepted by codechef .

sum = ((((int)pow(2,N-1)%(int)MOD)(A[j]%MOD)(A[j-1]%MOD))%MOD + (((A[j-1]%MOD)sum)/(2(A[j]%MOD)))%MOD)%MOD;

I just gave that code a quick look. Shouldnt this part give you overflow? Especially - (int)pow(2,N-1)%(int)MOD) ?? N can be upto 10^5, so its easily outside the allowed range.

I think you could use fast exponentiation here. (Please note, this problem is NOT a beginner problem and is placed in wrong section. If you’re new to programming, skip it till you complete the easy section.)

Thanks for your reply!

i want to ask it is not passing case 1 i.e for N < 10 but when i run custom input upto 10 digits it is working help.

@vijju123 yes ,exactly its not that easy problem for a beginner to solve.
i took more than 5 hour to understand the problem
still i dont know what supposed to do!! XD