fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. long long newton(int n,int k)
  6. {
  7. if(n==k||k==0)
  8. {
  9. return 1;
  10. }
  11.  
  12. double suma=1;
  13. for(int i=1;i<=k;i++)
  14. {
  15.  
  16. suma=suma*(n+1-i)/i;
  17. }
  18. return (long long)suma;
  19. }
  20.  
  21. int main()
  22. {
  23.  
  24. int n,k,T;
  25. std::ios_base::sync_with_stdio(false);
  26. cin>>T;
  27. for(int i=0;i<T;i++)
  28. {
  29. cin>>n>>k;
  30.  
  31. long long s=newton(n,k);
  32. cout<<s<<endl;
  33. }
  34. return 0;
  35. }
  36.  
  37.  
Success #stdin #stdout 0s 2864KB
stdin
5
0 0
1000 2
7 3
500 500
100 95
stdout
1
499500
35
1
75287519