# Mysterious sequence(MYSARA)

It’s my solution link during the contest
can someone tell me the mistake with my code…
Really can’t understand my mistake now also…will be thankful to you for my help with the mistake,
https://www.codechef.com/viewsolution/30682214

Firstly, pow is only used for floating point calculations. Instead we precompute the powers of 2. ans needs to be a long long int otherwise it causes an overflow. you also need to take mod everytime you multiply ans by x because ans would be somewhere around 10^{18} and multiplying it with a large number would even overflow a long long int.
Corrected code: https://www.codechef.com/viewsolution/30688436

love you man ,thanks alot

what is wrong with my code?
#include <bits/stdc++.h>

const unsigned long long M = 1000000007;

using namespace std;

long long int power(int x, unsigned int y)
{
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) * power(x, y / 2);
else
return x * power(x, y / 2) * power(x, y / 2);
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// #ifndef ONLINE_JUDGE
// // for getting input from input.txt
// freopen(“input.txt”, “r”, stdin);
// // for writing output to output.txt
// freopen(“output.txt”, “w”, stdout);
// #endif

``````long long t;
cin >> t;
while(t--){
long long n;
cin >> n;
long long arr[n];
for(int i = 0; i < n; ++i) cin >> arr[i];
long long count = 1;
int flag = 0;
for(int i = 0 ; i < n-1 ; ++i){
int d = __builtin_popcount(arr[i] & arr[i+1]);
count *= (power(2,d) % M);
if(arr[i] != (arr[i]&arr[i+1])) flag = 1;

}
if(flag) cout << "0\n" ;
else  cout << count << "\n";
}
return 0;
``````

}

`in line ---> count *= (power(2,d) % M);`