Problem : CodeChef: Practical coding for everyone

My code is not giving any answer in the 3rd test case of the problem.

I want to know what can be done to avoid memory overflow

My Code :

```
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int t; cin >>t;
while(t--)
{
long long int k,d0,d1;
cin >> k >> d0 >> d1;
long long int ans = d0 + d1;
long long int m = ans;
long long int n = pow(10,k-1)*d0 + pow(10,k-2)*d1;
k = k-2;
while(k!=0)
{
n += pow(10,k-1)*ans;
ans+= ans;
ans = ans%10;
k--;
}
cout <<n << endl;
}
return 0;
}
```