Ultra fast mathematician problem

my code is giving wrong answer for one testcase but the code is right…
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t>0)
{
int no1,no2,rem1=0,rem2=0;
cin>>no1>>no2;
int ans[100];
int i=0;
while(no1>0||no2>0)
{
rem1=no1%10;
rem2=no2%10;
if(rem1==rem2)
{
ans[i]=0;
i++;
}
else if(rem1!=rem2)
{
ans[i]=1;
i++;
}
no1=no1/10;
no2=no2/10;
}
for(i=i-1;i>=0;i–)
{
cout<<ans[i];
}
cout<<endl;
t–;
}
return 0;
}

Hi @soorya19k
You are getting wrong answer for test case in which no1 and no2 are greater than 10^9, because in that case no1 and no2 are out of range of hence it is showing wrong answer,. So to pass all the test cases just change int to long long.

Here is your corrected code :

If your doubt is clear then mark it as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.