[https://www.codechef.com/viewsolution/30842961]
It’s my solution link for SWPDGT
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,
You have done if(a==b) then return a+b , see if a=b=19.
Your answer is 19+19 ,
whereas the expected output is 99+11
Thank you
https://www.codechef.com/viewsolution/30844402
This is my perfectly running code have a look , if still not clear then mention me again I will debug .
#include
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;
int sum = a+b;
int dig1 = floor((log10(a) + 1));
int dig2 = floor((log10(b) + 1));
if(dig1==1 && dig2==1)
{
cout<<sum<<"\n";
}
else
{
int l = max(a,b);
int s = min(a,b);
if((l/10)>s%10)
{
int rem1 = l%10;
int div1 = l/10;
int rem2 = s%10;
int div2 = s/10;
div1 = div110 + div2;
rem1 = rem110 + rem2;
int check = div1+rem1;
if(check>sum)
cout<<check<<"\n";
else
cout<<sum<<"\n";
}
else
{
int rem1 = l%10;
int div1 = l/10;
int rem2 = s%10;
int div2 = s/10;
rem2 = rem210 + rem1;
div2 = div210 + div1;
int check = rem2+div2;
if(check>sum)
cout<<check<<"\n";
else
cout<<sum<<"\n";
}
}
}
return 0;
}
this is my code… why isn’t this working please tell me ??
[https://www.codechef.com/viewsolution/30848565]
Can someone please help me with the same question as well?