The link to the question is RGAME Problem - CodeChef. I tried my code in terminal it gave the correct answer for all the cases I tried. But here it shows wrong answer. Can anyone plz tell what is the problem and which case it is not working for?
my code is :
#include<iostream>
#include <math.h>
using namespace std;
long long power(long long a,long long b)
{
long long c=pow(a,b);
return c;
}
int main()
{
int t;
long long int M=1000000007;
cin>>t;
while(t--)
{
long long int n;
cin>>n;
long long int a[100002];
for(long long int i=0;i<=n;i++)
cin>>a[i];
long long int sum=0;
for(long long int k=0;k<n;k++)
{
for(long long int p=k+1;p<n+1;p++)
{
if(k==0)
sum=(sum+((power(2,n-p+1))%M*a[k]*a[p]%M)%M)%M;
else sum=(sum+( power(2,k))%M*(power(2,n-p))%M*(a[k]*a[p])%M)%M;
}
}
cout<<sum<<"\n";
}
return 0;}