11332  Summing Digits
Moderator: Board moderators
11332  Summing Digits
is there any algorithm for the problem? very east to understand but its really troubling.
Last edited by apurba on Wed Nov 14, 2007 8:23 am, edited 1 time in total.
Code: Select all
keep dreaming...
Re: 11332_summing digits is troubling very simply!!!!
It is the most trivial problem from that problem set.apurba wrote:is there any algorithm for the problem? very east to understand but its really troubling.

 New poster
 Posts: 13
 Joined: Fri Nov 03, 2006 2:53 pm
 Location: bangladesh
 Contact:
If a number is divisible by 9 the sum of its digits succesively reduced to 9
or the sum of digits will be reduced to num mod 9.
As for xample 198 = 1+9+8 = 18 = 1+8 = 9 (as 198 mod 9 == 0)
agan 203 = 2+0+3 = 5 (203 mod 9 =5)
so in this problem one doesn't need to calculate any summation but simply mod operation by 9.
S.M.Ferdous
or the sum of digits will be reduced to num mod 9.
As for xample 198 = 1+9+8 = 18 = 1+8 = 9 (as 198 mod 9 == 0)
agan 203 = 2+0+3 = 5 (203 mod 9 =5)
so in this problem one doesn't need to calculate any summation but simply mod operation by 9.
S.M.Ferdous
Re: 11332  Summing Digits
My bad luck why every time it's me getting WA...
Can someone check this.
Can someone check this.
Code: Select all
Got Accepted
Last edited by Obaida on Mon May 26, 2008 5:49 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re:
Obaida wrote:My bad luck why every time it's me getting WA...
Can someone check this.
Try this input
Code: Select all
9
18
27
0
Code: Select all
9
9
9
Re: 11332  Summing Digits
Thank you helloneo that was a misunderstanding. I got Accepted.
try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 11332  Summing Digits
Code: Select all
This is a very is ploblem in this volume.
Re: 11332  Summing Digits
I am getting wrong answer with this code. Please help me
Code: Select all
Accepted
Last edited by mrmbdctg on Thu Aug 14, 2008 9:27 pm, edited 1 time in total.
Re: 11332  Summing Digits
my algorithm is
this algorithm isn't very fast, but it works
Code: Select all
1. int sum = add every digit of n, since n is at most 2,000,000,000, sum has two digits at most.
2. int temp = sum/10 + sum %10
3. if temp < 10, print temp
else print temp / 10 + temp % 10