/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define M 1000000007
long long int a[60];
long long int combination (long long int a,long long int b);
int main()
{
long long int t,n,k,i,count,result;
scanf("%lli",&t);
while(t–){
count=0;
scanf("%lli %lli",&n,&k);
for(i=0;i<n;i++)
scanf("%lli",&a[i]);
mergeSort(a,0,n-1);
i=0;
while(a[k-1]==a[k+i]){
count++;
i++;
}
count=count+k;
result=combination(count,k);
//for(i=0;i<n;i++)
// printf("%lli “,a[i]);
//printf(”\n");
printf("%lli\n",result);
}
return 0;
}
void merge(long long int arr[], long long int l, long long int m,long long int r)
{
long long int i, j, k;
long long int n1 = m - l + 1;
long long int n2 = r - m;
/* create temp arrays */
long long int L[n1], R[n2];
/* Copy data to temp arrays L[] and R[] */
for (i = 0; i < n1; i++)
L[i] = arr[l + i];
for (j = 0; j < n2; j++)
R[j] = arr[m + 1+ j];
/* Merge the temp arrays back into arr[l..r]*/
i = 0; // Initial index of first subarray
j = 0; // Initial index of second subarray
k = l; // Initial index of merged subarray
while (i < n1 && j < n2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}
/* Copy the remaining elements of L[], if there
are any */
while (i < n1)
{
arr[k] = L[i];
i++;
k++;
}
/* Copy the remaining elements of R[], if there
are any */
while (j < n2)
{
arr[k] = R[j];
j++;
k++;
}
}
/* l is for left index and r is right index of the
sub-array of arr to be sorted */
void mergeSort(long long int arr[], long long int l, long long int r)
{
if (l < r)
{
// Same as (l+r)/2, but avoids overflow for
// large l and h
long long int m = l+(r-l)/2;
// Sort first and second halves
mergeSort(arr, l, m);
mergeSort(arr, m+1, r);
merge(arr, l, m, r);
}
}
long long int combination (long long int a,long long int b){
if(b==0)
return 1;
if(b==a)
return 1;
return combination(a-1,b-1)+ combination(a-1,b);
}
whats the problem in this code