http://www.codechef.com/viewsolution/3646160 kindly help :) asked 26 Mar '14, 00:15

Your approach is correct. The basic error in your code is that you have take the data type of the variable i as integer and then you are multiplying two integers and storing the result in long long int. But 10^5 * 10^5 would overflow integer and hence a negative value will go inside num (long long int) variable. Correct that error. answered 26 Mar '14, 02:33

at n=10000000000 its giving an answer of 99 while it should give 117.. i am not able to understand the error which i have made.