# Practice-concered Questions:Medium-Count Number

```#include <iostream>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

#define maxNum 500005
#define modulo 1000000007

using namespace std;

/*
||=== Build: Debug in Count Number (compiler: GNU GCC Compiler) ===|
GeeksforGeeks Practice\Medium\Count Number\main.cpp|60|error: size of array 'CombiModulated' is too large|
GeeksforGeeks Practice\Medium\Count Number\main.cpp||In function 'int main()':|
GeeksforGeeks Practice\Medium\Count Number\main.cpp|74|error: 'CombiModulated' was not declared in this scope|
||=== Build failed: 2 error(s), 3 warning(s) (0 minute(s), 0 second(s)) ===|
*/
int T=0,N=0,K=0,X=0,lft=0,rgt=0,arr[maxNum],CombiModulated[maxNum][maxNum];

struct subset {
int start;
int finish;
} possibilities[maxNum];

unsigned long long int ans = 0L;

int main() {
memset(CombiModulated,0,sizeof(CombiModulated));

for(int n=0; n<maxNum; ++n) {
for(int r=0; r<maxNum; ++r) {
if(n==0||r==0) {
CombiModulated[n][r]=1;
} else if(r>n) {
CombiModulated[n][r]=0;
} else if(n==r) {
CombiModulated[n][r]=1;
} else {
CombiModulated[n][r]=((CombiModulated[n-1][r])%modulo+(CombiModulated[n-1][r-1])%modulo)%modulo;
}
}
}

while(scanf("%d",&T)==1) {

while(T--) {

memset(arr,0,sizeof(arr));

for(int i=0; i<maxNum; ++i) {
possibilities[i].start = possibilities[i].finish=0;
}

N=0,K=0,X=0,ans=0L,lft=0,rgt=0;

scanf("%d%d%d",&N,&K,&X);

for(int i=0; i<N; i++) {
scanf("%d",&arr[i]);
}

sort(arr,arr+N);

int tmp=0,j=0;

for(int i=0; i<N; i++) {
tmp = lft = i;
possibilities[j].start=lft;

while(tmp<N&&(arr[tmp]-arr[lft]<=X)) {
++tmp;

if(tmp==N) {
break;
}
}
possibilities[j].finish=tmp-1;

++j;

}

int i=0;

printf("i=%d,possibilities[%d].start=%d,possibilities[%d].finish=%d\n",0,0,possibilities[0].start,i,possibilities[0].finish);

for(i=1; i<N; ++i) {
if(possibilities[i].finish>possibilities[i-1].finish) {
printf("i=%d,possibilities[%d].start=%d,possibilities[%d].finish=%d\n",i,i,possibilities[i].start,i,possibilities[i].finish);
}
system("PAUSE");
}

printf("%llu\n",ans%modulo);
}
}

return 0;
}```

Hi all:Does anyone knows how to solve this one in C/C++?Java has BigInteger class but STL has nothing similar...
I tried to calculate combinations with large numbers like C(500000,305) defined in constraints of this prob:1≤N≤5*10^5,1≤K≤N.
while declaring a 2d-array of int type to store the numbers of combination I got my compiler showing error message the size of the array is too large...
Plz help to check my code above.(My local compiler error message are listed as comments.)

Thank you!