yes, you have already calculated it for first value... so need not compute
it again
On Fri, Sep 30, 2011 at 1:21 AM, .itoa wrote:
> sumOfDigits has to be called for ALL values. we need to check sum for all
> possible values which are divisible by x.
>
> --
> You received this message because yo
sumOfDigits has to be called for ALL values. we need to check sum for all
possible values which are divisible by x.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/alg
Yeah , that is exactly what my question is. How to optimize ?
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/algogeeks/-/Fu6ZwU144ocJ.
To post to this group, send emai
that's a brute force approach, obviously it won't work.
On Fri, Sep 30, 2011 at 12:52 AM, .itoa wrote:
> This is the question : https://hs.spoj.pl/problems/HS11DIVS/ [ Count the
> numbers ! - HS11DIVS ]
>
> And here is my attempt : http://ideone.com/yynjH
>
> Now , my problem is that the code wo
But i need to calculate the sum of digits for all values of a (those which
are divisible by x). Are you trying to say that i should place this line :
Line 36 sum = sumOfDigits(a);
outside the while loop ?
--
You received this message because you are subscribed to the Google Groups
"
i think you can avoid calculating sumOfDigits(a) each time. Similarly
compute for all the values directly.
On Fri, Sep 30, 2011 at 1:11 AM, .itoa wrote:
> Yeah , that is exactly what my question is. How to optimize ?
>
> --
> You received this message because you are subscribed to the Google Gr
This is the question : https://hs.spoj.pl/problems/HS11DIVS/ [ Count the
numbers ! - HS11DIVS ]
And here is my attempt : http://ideone.com/yynjH
Now , my problem is that the code works fine with small numbers ( even with
1 ) , but with larger number , time limit exceeds. How to make it