fork(1) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int fact(int a) {
  7. return (a==1 || a==0) ? 1 : fact(a-1)*a;
  8. }
  9.  
  10. int cmp(const void *a, const void *b) {
  11. return (*(int*)b - *(int*)a);
  12. }
  13.  
  14. int main() {
  15. int t, p[12], k, k_th, in, out, tot;;
  16. scanf("%d", &t);
  17. while(t--) {
  18. for(int i=0; i<11; i++) scanf("%d", &p[i]); scanf("%d", &k);
  19. qsort(p, 11, sizeof(int), cmp);
  20. k_th=p[k-1]; in=out=tot=0;
  21. for(int i=0; i<k; i++) if(k_th==p[i]) in++;
  22. for(int i=k; i<11; i++) if(k_th==p[i]) out++;
  23. tot=in+out;
  24. printf("%d\n", fact(tot)/(fact(in)*fact(tot-in)));
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 3344KB
stdin
2
1 2 3 4 5 6 7 8 9 10 11
3
2 5 1 2 4 1 6 5 2 2 1
6
stdout
1
6