this problem is same as *http://www.codechef.com/problems/MARBLES/* solution to this are public u can check for more clarification
On Tue, Jun 21, 2011 at 3:51 PM, sunny agrawal <sunny816.i...@gmail.com>wrote: > if it is given tha final answer fits in 64 bit signed integer then > > we can run a loop for i = n-r+1 to n > keeping result in a 64 bit signed integer > each time multiplying with i > > in this loop we need to add some code that will divide the result with r! > to do this initialize a int j to 1 > and each iteration check if the ans is divisible by j > keep dividing utill j divides ans or j = r+1 > > that will look like O(r^2) but we will be dividing with only r values so it > will be O(2*r) = O(r) > > -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.