The answer for test case of n as 30 and k as 7 is showing answer 0 . Below is my code.
#include <bits/stdc++.h>
using namespace std;
int fact(int n)
{
if(n==0 || n==1)
{
return 1;
}
return n * fact(n-1);
}
int main()
{
int t;
cin>>t;
while (t–)
{
int n,k;
cin>>n>>k;
int ans = fact(n-1) / (fact(k-1) * fact(n-k));
cout<<ans<<endl;
}
return 0;
}