×

# Problem1 in Peer section

 1 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. asked 02 Nov '14, 20:30 2★tataisap 24●5 accept rate: 0%

 1 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. answered 02 Nov '14, 22:49 206●1●2●9 accept rate: 9% its still not working!! :( Link: http://www.codechef.com/viewsolution/5262358 (03 Nov '14, 00:55) tataisap2★ 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. (03 Nov '14, 01:50) Not working! Link: http://www.codechef.com/viewsolution/5263174 (03 Nov '14, 13:30) tataisap2★ O sorry i had mistakenly deletedthe \n so it wasnt working now ive got it thank you very much:) (03 Nov '14, 13:49) tataisap2★ Cheers! :-) (03 Nov '14, 15:24)
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×846
×193

question asked: 02 Nov '14, 20:30

question was seen: 544 times

last updated: 03 Nov '14, 15:24