why is my code failing for 2 testcases??i have also tried to optimise the factorial computation by dividing if possible instead of multiplying same question codechef i got an AC
https://www.codechef.com/submit/MARBLES
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
ll fact(ll n, ll r)
{
r = min(r,n-r);
ll res = 1;
for(ll i=0; i<r; i++)
{
if(res%(i+1) == 0)
res = res/(i+1)*(n-i);
else if((n-i)%(i+1) == 0)
res = (n-i)/(i+1)*res;
else
res = res*(n-i)/(i+1);
}
return res;
}
int main()
{
int t;
cin>>t;
while(t--)
{
ll n, k;
cin>>n;
cin>>k;
if(k>n)
cout<<0<<endl;
else
cout<<fact(n-1,k-1)<<endl;
}
}