Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-29 Thread UTKARSH SRIVASTAV
hi see the logic all the factors of a number are evenly distributed about it's square root for e.g 100 1 X 100 2 X 50 4 X 25 5 X 20 10 X 10 AFTER THIS THE PAIRS REPEATE THEMSELVES BUT IN OPPOSITE ORDER 20 X 5 25 X 4 50 X 2 100 X 1 SO IF YOU MAKE YOUR LOOP GO TO SQRT(N) AND IF YOU FIND A FACTOR OF

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-28 Thread kartik sachan
it can be simply done in O(sqrt(n)) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Gaurav Menghani
Yeah, sorry I was giving a hint for DIVSUM2, which is a much harder version of DIVSUM. You are checking all numbers less than n for divisibility. This is O(n). Figure out how can you find the set of divisors using primes. This can be done in O(2^d), if there are d prime divisors. On Sat, Aug 27

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Gaurav Menghani
http://lmgtfy.com/?q=pollard%27s+rho+algorithm On Sat, Aug 27, 2011 at 11:05 PM, Rahul Verma wrote: > @gaurav Thanks dear > Could you please explain the algorithm. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this disc

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread saurabh modi
you could use seiving.its fast.its practical. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.c

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Rahul Verma
@gaurav Thanks dear Could you please explain the algorithm. -- 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/-/TNa8UygkzGkJ. To post to this group, send e

Re: [algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Gaurav Menghani
You might want to check out Pollard Rho algorithm. On Sat, Aug 27, 2011 at 9:57 PM, Rahul Verma wrote: > I am trying to submit solution for the SPOJ DIVSUM problem, but it returns > the time limit exceeded. Code submitted by me is below: > > #include > #include > using namespace std; > int prop

[algogeeks] SPOJ Problem DIVSUM

2011-08-27 Thread Rahul Verma
I am trying to submit solution for the SPOJ DIVSUMproblem, but it returns the *time limit exceeded*. Code submitted by me is below: #include #include using namespace std; int proper_divisor(int number); int main() { int test,i,number; cin>>test;