-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathНовий порожній файл
90 lines (63 loc) · 1.41 KB
/
Новий порожній файл
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <cmath>
#include <bitset>
#include <ctime>
#include <random>
#include <string>
using namespace std;
long factorial(int n)
{
int counter;
long fact = 1;
for (int counter = 1; counter <= n; counter++)
{
fact = fact * counter;
}
return fact;
}
float comb(float n , float m){
float res;
res=factorial(n)/(factorial(m)*factorial(n-m));
return res;
}
int main() {
srand(time(NULL));
int ti = 2;
const int Np = 16;
int k = log2(Np);
int dmin = 2 * ti + 1;
float sumNpC = 0;
int r = 0;
for (int i = 0; i < dmin; i++) {
for(int j = 1;j<dmin; j++){
sumNpC+=comb(k+r,j);
}
if (r >= log2(1+sumNpC)) {
break;
}
else r++;
}
int n = k + r;
cout << n;
const int n1 = n;
int **Grk = new int*[r];
for (int i = 0; i < r; i++) {
Grk[i] = new int[k];
}
int mas [Np];
bitset<n1> komb;
komb.set();
int numb = (int)(komb.to_ulong());
a:
for (int i = 0; i<Np; i++) {
int rnd = rand() % numb + 1;
mas[i] = rnd;
} //äâà öèêëè ùîá çàïîâíèòè ìàñèâ ðàíä çíà÷åííÿìè áåç ïîâòîðåíü
for (int i = 0; i<Np - 1; i++)
{
for (int j = i + 1; j<Np; j++)
if (mas[j] == mas[i])
goto a;
}
return 0;
}