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. int t, s, totol=1, d, ans=1;
  9. int a,b;
  10. scanf("%d", &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. }for(int j=1;j<b+1;j++){
  21. ans /= j;
  22. }
  23. for(int w=1;w<b+1;w++){
  24. totol *= (a-w+1);
  25. }for(int w=1;w<b+1;w++){
  26. totol /= w;
  27. }
  28. s=totol;
  29. d=totol-ans;
  30. if(a==1&&b==1){
  31. printf("1 0");
  32. }else{
  33. printf("%d %d\n", s, d);
  34. }
  35. }
  36. }
Success #stdin #stdout 0.01s 5284KB
stdin
1
20 10
stdout
117 106