Hello,
In my project I am trying to get all combination between 2 numbers, for example if I have 2 array the first one store the min bound and the second one store the max bound,so arr1[3] = {1,1,2} and the arr2 = {2,2,3} so I should build a 2d array store all combination which are
112, 212, 122, 222, 113, ..., 223.
first I calculate the number of row of the 2d array and since the number of element of min and max are vary between 10 and 20, it sometime give me a large number which need to build a huge array, my code is:
unsigned long long row =0; unsigned long long rh1 = 1;
for(int i=0; i<col;++i) {
rh1 *= t_end[i] - t_s[i] + 1;row += rh1;
cout << "Row= "<< row <<endl;
}
so some time the number (row) become so large and can't handle this value, for example if I have the following min and max bound:
t_s = {3 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 }
t_end = {2 2 3 4 6 10 3 11 11 13 4 15 8 9 19 19 20 23 27 10 }
then the row will be as follow:
Row= 4
Row= 32
Row= 144
Row= 1152
Row= 11232
Row= 112032
Row= 1120032
Row= 14224032
Row= 92848032
Row= 1193584032
Row= 16603888032
Row= 309399664032
Row= 2944561648032
Row= 53012639344032
Row= 1104442270960032
Row= 24235894166512032
Row= 278681865017584032
Row= 6894277107145456032
Row= 12879056739084163488
Row= 5417061573465168288 --- this value is smaller than previous and this is wrong
and sometime the Row value become negative, so how to solve this issue, and for of course I cant build an array with this huge number of row, and I was thinking to divide it, but I can't get the number of row that allow me to calculate the number of sub-array I should have.
Other question, what is the max size of array that I could have and how to know that.