Problem1 in Peer section

Sorry to bother you again but can plz help me understand ehy im getting WA for Problem 1(Problem code: CMB01) of peer section. Link to my submission: http://www.codechef.com/viewsolution/5260510 Thank you in advance again.

1 Like

Well,you are getting WA because your code for reversing the number is not actually reversing the number.after the execution of for loop the right most digit of the number is used in addition.i.e
if the number is 12345,then in each iteration you are updating a1 as mod of number/10,i.e
iteration no.1 : a1=12345%10=5
iteration no.2 :a1=1234%10=4
iteration no.3 : a1=123%10=3
iteration no.4 : a1=12%10=2
iteration no.5 : a1=1%10=1
thus your reversing code is outputting the right most digit of number.Rather than writing
for(int i=0;a>0;i++)
{ a1=a%10;
a/=10;}
Try this
for(int i=0;a>0;i++)
{ a1=a1*10;
a1=a1+a%10;
a/=10;}
This will give you the reversed number.Do check it out.Do the same editing for other ‘for’ loops too.

1 Like

its still not working!! :frowning:
Link: http://www.codechef.com/viewsolution/5262358

Hey,why are you printing the reversed nos. i.e a and b,that is not asked.You have to give the output as asked in the question,just remove those printf’s for integers separately,n only print the final sum.This should get you AC.Try it.

Not working! Link: http://www.codechef.com/viewsolution/5263174

O sorry i had mistakenly deletedthe \n so it wasnt working now ive got it thank you very much:)

Cheers! :slight_smile: