for the problem Marbles : http://www.codechef.com/problems/MARBLES here is the code.
But the problem is code chef is returning SIGSEGV error and i am unable to find out the problem in my code. So please tell me can my code be modified to fit the conditions of the question or do i have to think from a new perspective?
here is the code:
#include<iostream>
using namespace std;
long long int C(int n,int r)
{
if(r==1)
return n;
if(n==r)
return 1;
long long int c=C(n-1,r)+C(n-1,r-1);
return c;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n,r;
cin>>n>>r;
cout<<C(n-1,r-1)<<endl;
}
}