// 02: random // 03: N = 1000, R = 20 // 04: N = 200, R = 20, D == P // 05: N = 200, R = 20, D < P // 06: N = 10, R = 1 #include #include #include using namespace std; random_device rd; default_random_engine e1(rd()); int rand_int(int low, int high) { uniform_int_distribution uniform_dist(low, high); return uniform_dist(e1); } string rand_str(int len) { string s; for (int i = 0; i < len; i++) { int x = rand_int(0, 51); if (x > 25) { s += (char)('A' + x - 26); } else { s += (char)('a' + x); } } return s; } int main() { // just generate a bunch of random instances int N = 200; cout << N << endl; for (int i = 0; i < N; i++) { int R, P, D; R = rand_int(1, 20); R = 20; P = rand_int(2, 12); D = rand_int(1, P-1); cout << R << ' ' << P << ' ' << D << endl; int main_index = rand_int(0, R-1); int weight[20], perc[20]; for (int i = 0; i < R; i++) { weight[i] = rand_int(1,10000); } for (int i = 0; i < R; i++) { if (i == main_index) { perc[i] = 1000; } else { // more or less rounding... while (true) { perc[i] = (weight[i] * 1000 + weight[main_index]/2)/ weight[main_index]; if (perc[i] != 1000) break; weight[i] += 100; } } } for (int i = 0; i < R; i++) { cout << rand_str(20) << ' '; cout << weight[i]/10 << '.' << weight[i]%10 << ' '; cout << perc[i]/10 << '.' << perc[i]%10; cout << endl; } } return 0; }