// 01-02: sample // 03-07: equal curves of size n = 1, 2, 3, 5, 10 // 08-16 : random curves of size n = 2, 3, 4, 5, 6, 7, 8, 9, 10 #include #include #include #include #include #include #include #include using namespace std; const string probname = "studying"; 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); } double myround(double x) { return floor(x * 10000.0 + 0.5)/10000.0; } double myfloor(double x) { return floor(x * 10000.0)/10000.0; } void gen_poly(int T, double &a, double &b, double &c) { bool good; do { int M = rand_int(50,100); double A = M / ((double)T*T); a = -A; b = 2*T*A; c = 99 - A*T*T; a = myround(a); b = myround(b); c = myround(c); good = (c >= 0) && a*T*T+b*T+c <= 100 && a < 0 && b >= 0 && (2*a*T+b >= 0); } while (!good); } void gen_rand(int n, int c) { ostringstream oss; oss << probname << "-" << setw(2) << setfill('0') << c << ".in"; ofstream os(oss.str().c_str()); int T = rand_int(1,240); os << n << ' ' << T << endl; for (int i = 0; i < n; i++) { double A, B, C; gen_poly(T, A, B, C); os << fixed << setprecision(4) << A << ' ' << B << ' ' << C << endl; } } void gen_equal(int n, int c) { ostringstream oss; oss << probname << "-" << setw(2) << setfill('0') << c << ".in"; ofstream os(oss.str().c_str()); int T = rand_int(1,240); os << n << ' ' << T << endl; double A, B, C; gen_poly(T, A, B, C); for (int i = 0; i < n; i++) { os << fixed << setprecision(4) << A << ' ' << B << ' ' << C << endl; } } int main() { int c = 1; gen_equal(2, c++); gen_equal(3, c++); gen_equal(1, c++); gen_equal(2, c++); gen_equal(3, c++); gen_equal(5, c++); gen_equal(10, c++); for (int s = 2; s <= 10; s++) { gen_rand(s, c++); } return 0; }