#include #include #include #include #include using namespace std; const double pi = acos(-1); mt19937 mt(123456); int t; long double p, w, v, gx, gy; long double hypot2(long double x, long double y) { return x*x + y*y; } bool solve2() { long double gr = hypot(gx, gy); long double mn = 1e100; long double x = v+1; long double y = w; long double det = (1+v)*(1+v) + w*w; long double gx = ::gx; long double gy = ::gy; if (t >= 2 && hypot2(x, y) + hypot2(gx, gy) < p - 0.00001) { cerr << "type1" << endl; printf("%.30Lf %.30Lf\n", -x, -y); for (int j = 0; j < t - 2; j++) { printf("%.30Lf %.30Lf\n", 0.0L, 0.0L); } printf("%.30Lf %.30Lf\n", gx, gy); return true; } for (int i = 0; i < t - 1; i++) { long double gx0 = gx; long double gy0 = gy; gx = gx0*(v+1) + gy0*w; gy = gy0*(v+1) - gx0*w; gx /= det; gy /= det; long double dist = hypot(gx, gy); long double score = dist*dist + x*x + y*y; if (score < p - 0.00001) { cerr << "type2" << endl; printf("%.30Lf %.30Lf\n", -x, -y); for (int j = 0; j < t - 3 - i; j++) { printf("%.30Lf %.30Lf\n", 0.0L, 0.0L); } printf("%.30Lf %.30Lf\n", gx, gy); printf("%.30Lf %.30Lf\n", 0.0L, 0.0L); return true; } } return false; } bool solve() { long double gr = hypot(gx, gy); long double mn = 1e100; for (int ii = 0; ii < 5000; ii++) { long double x = 1; long double y = 0; vector vx(t); vector vy(t); long double theta = uniform_real_distribution(0, 2*pi)(mt); long double c = uniform_real_distribution(1e-6, 10)(mt); vx[0] = cos(theta) - 1; vy[0] = sin(theta); for (int i = 0; i < t; i++) { long double x0 = x; long double y0 = y; x = x0 - y0*w + x0*v + vx[i]; y = y0 + x0*w + y0*v + vy[i]; long double r = hypot(x, y); long double tr; tr = gr*pow((long double)i / t, c); long double d = tr - r; vx[i] += d*x / r; vy[i] += d*y / r; x += d*x / r; y += d*y / r; } vx[t - 1] += gx - x; vy[t - 1] += gy - y; long double s = 0; for (int i = 0; i < t; i++) { s += vx[i]*vx[i] + vy[i]*vy[i]; } mn = min(mn, s); if (s < p - 0.001) { cerr << "type3" << endl; for (int i = 0; i < t; i++) { printf("%.16Lf %.16Lf\n", vx[i], vy[i]); } fprintf(stderr, "Sum: %.30Lf\n", s); fprintf(stderr, "p: %.30Lf\n", p); return true; } } return false; } int main() { int T; cin >> T; while (T--) { cin >> t >> p >> w >> v >> gx >> gy; if (!solve2()) { solve(); } } }