I am getting wrong answer even my output is correct

I don’t know why in CodeChef my answer is getting wrong as in codeblocks my output is correct
here is the link of the solution https://www.codechef.com/viewsolution/35622043
please help me!

If testcase is single digit
it should give twice the value of number since that is both first and last digit of a number.
just add this after taking input


This is your updated code

1 Like

oohh , so here i was mistaking.
Thank you so much for help.

A better way of finding the first digit is:

while(n > 9)

Just putting it out there.

It takes log_{10} n time though. But that shouldn’t be a problem for most applications.

1 Like