-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetWidth.h
151 lines (148 loc) · 5.73 KB
/
GetWidth.h
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <iostream>
using namespace std;
#include "GetPrimeFactor.h"
vector<vector<int>> getWidth(int numberOfProcess) {
int t_n;
vector<int> v;
vector<int> x;
t_n = numberOfProcess;
x.push_back(1);
v = getPrimeFactor(t_n);
for (int i = 0; i < v.size(); i++) {
if (x[x.size() - 1] != v[i]) {
x.push_back(v[i]);
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
if (x[x.size() - 1] != v[i] * v[j]) {
x.push_back(v[i] * v[j]);
}
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
if (x[x.size() - 1] != v[i] * v[j] * v[k]) {
x.push_back(v[i] * v[j] * v[k]);
}
}
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
for (int l = k + 1; l < v.size(); l++) {
if (x[x.size() - 1] != v[i] * v[j] * v[k] * v[l]) {
x.push_back(v[i] * v[j] * v[k] * v[l]);
}
}
}
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
for (int l = k + 1; l < v.size(); l++) {
for (int m = l + 1; m < v.size(); m++) {
if (x[x.size() - 1] != v[i] * v[j] * v[k] * v[l] * v[m]) {
x.push_back(v[i] * v[j] * v[k] * v[l] * v[m]);
}
}
}
}
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
for (int l = k + 1; l < v.size(); l++) {
for (int m = l + 1; m < v.size(); m++) {
for (int n = m + 1; n < v.size(); n++) {
if (x[x.size() - 1] != v[i] * v[j] * v[k] * v[l] * v[m] * v[n]) {
x.push_back(v[i] * v[j] * v[k] * v[l] * v[m] * v[n]);
}
}
}
}
}
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
for (int l = k + 1; l < v.size(); l++) {
for (int m = l + 1; m < v.size(); m++) {
for (int n = m + 1; n < v.size(); n++) {
for (int o = n + 1; o < v.size(); o++) {
if (x[x.size() - 1] != v[i] * v[j] * v[k] * v[l] * v[m] * v[n] * v[o]) {
x.push_back(v[i] * v[j] * v[k] * v[l] * v[m] * v[n] * v[o]);
}
}
}
}
}
}
}
}
for (int i = 0; i < v.size(); i++) {
for (int j = i + 1; j < v.size(); j++) {
for (int k = j + 1; k < v.size(); k++) {
for (int l = k + 1; l < v.size(); l++) {
for (int m = l + 1; m < v.size(); m++) {
for (int n = m + 1; n < v.size(); n++) {
for (int o = n + 1; o < v.size(); o++) {
for (int p = o + 1; p < v.size(); p++) {
if (x[x.size() - 1] != v[i] * v[j] * v[k] * v[l] * v[m] * v[n] * v[o] * v[p]) {
x.push_back(v[i] * v[j] * v[k] * v[l] * v[m] * v[n] * v[o] * v[p]);
}
}
}
}
}
}
}
}
}
vector<int> y = x;
vector<int> z = y;
vector<int> h = z;
vector<int> g = h;
vector<int> f = g;
vector<int> e = f;
vector<int> d = e;
vector<int> tree_structure;
vector<vector<int>> tree;
for (int i = 0; i < x.size(); i++) {
for (int j = 0; j < y.size(); j++) {
for (int k = 0; k < z.size(); k++) {
for (int l = 0; l < h.size(); l++) {
for (int m = 0; m < g.size(); m++) {
for (int n = 0; n < f.size(); n++) {
for (int o = 0; o < e.size(); o++) {
for (int p = 0; p < d.size(); p++) {
if (x[i] * y[j] * z[k] * h[l] * g[m] * f[n] * e[o] * d[p] == t_n) {
int a[] = {x[i], y[j], z[k], h[l], g[m], f[n], e[o], d[p]};
for (int it = 0; it < sizeof(a) / sizeof(int); ++it) {
if (a[it] == 1) {
continue;
} else {
tree_structure.push_back(a[it]);
}
}
tree.push_back(tree_structure);
tree_structure.clear();
}
}
}
}
}
}
}
}
}
sort(tree.begin(), tree.end());
tree.erase(unique(tree.begin(), tree.end()), tree.end());
tree.pop_back();
return tree;
}