fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <ctype.h>
  5. #include <string.h>
  6.  
  7. int main(){
  8. long long t, s, totol=1, d, ans=1;
  9. int a,b;
  10. scanf("%lld", &t);
  11. for(int k=0;k<t;k++){
  12. totol=1, ans=1;
  13. scanf("%d %d", &a, &b);
  14. if(b>(a-b+1)){
  15. ans=0;
  16. b=a-b;
  17. }
  18. for(int j=1;j<b+1;j++){
  19. ans *= (a-b+2-j);
  20. ans /= j;
  21. }
  22. for(int w=1;w<b+1;w++){
  23. totol *= (a-w+1);
  24. totol /= w;
  25. }
  26. s=totol;
  27. d=totol-ans;
  28. if(a==1&&b==1){
  29. printf("1 0");
  30. }else{
  31. printf("%lld %lld\n", s, d);
  32. }
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5284KB
stdin
1
20 10
stdout
184756 184745