Hey I was solving this with using BigInteger class and getting runtime error, although I fixed all corner test cases. Here is my java code:
import java.util.*;
import java.lang.*;
import java.math.BigInteger;
class Main
{
public static void main (String[] args)
{
Scanner scanner = new Scanner(System.in);
int t=scanner.nextInt();
while(t>0){
long n=scanner.nextLong();
int k=scanner.nextInt();
if(n<k||n==0 || k==0){
System.out.println(0);
}else{
BigInteger N=new BigInteger(Long.toString(n));
BigInteger ans=new BigInteger("1");
BigInteger one=new BigInteger("1");
for(int i=1;i<=k;++i){
BigInteger I= new BigInteger(Integer.toString(i));
ans=ans.multiply(one.add(N.subtract(I)));
ans=ans.divide(I);
}
System.out.println(ans);}
t--;
}
}
}