Can someone tell me whats wrong with my code
https://www.hackerrank.com/challenges/xor-and-sum/problem
Code
#include <bits/stdc++.h>
using namespace std;
/*
* Complete the 'xorAndSum' function below.
*
* The function is expected to return an INTEGER.
* The function accepts following parameters:
* 1. STRING a
* 2. STRING b
*/
unsigned long long int convert(string s)
{
reverse(s.begin(), s.end());
unsigned long long int ans = 0;
unsigned long long int n = s.length();
unsigned long long int mul =1 ;
for(unsigned long long int i = 0 ; i<n; i++)
{
ans+=mul*(s[i]=='1');
mul*=2;
}
return ans ;
}
unsigned long long int xorAndSum(string a, string b) {
unsigned long long int mod = 1000000007;
unsigned long long int a1 = convert(a);
unsigned long long int b1 = convert(b);
long long int ans =0 ;
cout<<a1<<endl;
cout<<b1<<endl;
for(int i =0 ; i <=314159 ; i++)
{
unsigned long long int bn = (b1<<i)%mod;
ans = (ans + (a1^bn)%mod)%mod;
// b1= (b1*2)%1000000007;
// cout<<ans<<endl;
}
return ans ;
}
int main()
{
ofstream fout(getenv("OUTPUT_PATH"));
string a;
getline(cin, a);
string b;
getline(cin, b);
long long int result = xorAndSum(a, b);
fout << result << "\n";
fout.close();
return 0;
}