@sharad : yes... prime number generation for RSA :P
-Rohit

On Sun, Mar 7, 2010 at 3:19 PM, Rohit Saraf <rohit.kumar.sa...@gmail.com>wrote:

> even my code would work if u make everything long long... i guess..
>
> -Rohit
>
>
>
> On Sun, Mar 7, 2010 at 3:15 PM, B |_ /\ C |<--D ! /\ /\/\ O /\| D <
> patidarc...@gmail.com> wrote:
>
>> long long r=N-K<K?(N-K):K;//chose small to miimize the loop
>> int n=N-(N-r)+1;
>> r=1;
>>  long long res=1;
>> for(long long i=n;i<=N;i++)
>> {
>>  res=res*i;
>> res=res/r++;
>> }
>>  cout<<res<<endl;
>> //-----------------------------------
>> this is working ...code...
>>
>> On Sun, Mar 7, 2010 at 3:12 PM, Anil C R <cr.a...@gmail.com> wrote:
>>
>>> doesn't work for big numbers :P
>>> Anil
>>>
>>>
>>>
>>> On Sun, Mar 7, 2010 at 2:53 PM, Rohit Saraf <rohit.kumar.sa...@gmail.com
>>> > wrote:
>>>
>>>> Here is the code if you want... i have not written it...
>>>> it's directly copied from wiki :)
>>>>
>>>> unsigned long long choose(unsigned n, unsigned k) {
>>>>     if (k > n)
>>>>         return 0;
>>>>
>>>>     if (k > n/2)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>         k = n-k; // Take advantage of symmetry
>>>>
>>>>     long double accum = 1;
>>>>     unsigned i;
>>>>     for (i = 1; i <= k; i++)
>>>>          accum = accum * (n-k+i) / i;
>>>>
>>>>     return accum + 0.5; // avoid rounding error
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> }
>>>>
>>>> call choose(n-1,k-1);
>>>>
>>>>
>>>> -Rohit
>>>>
>>>>
>>>>
>>>> On Sun, Mar 7, 2010 at 2:49 PM, Rohit Saraf <
>>>> rohit.kumar.sa...@gmail.com> wrote:
>>>>
>>>>> The answer is simply  : (N-1) Choose (k-1)
>>>>>
>>>>>
>>>>> -Rohit
>>>>>
>>>>>
>>>>>
>>>>> On Sun, Mar 7, 2010 at 2:11 PM, naga vinod kumar <
>>>>> vinodkumark...@gmail.com> wrote:
>>>>>
>>>>>> How to solve this problem....
>>>>>>
>>>>>> http://www.codechef.com/problems/MARBLES/
>>>>>>
>>>>>>
>>>>>> K.Naga Vinod Kumar
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algoge...@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>>>>> .
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>
>>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algoge...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>>> .
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algoge...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algoge...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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.

Reply via email to