#include #define VARNAME(x) #x #define show(x) cerr << #x << " = " << fixed << setprecision(30) << x << endl using namespace std; using ll = long long; using ld = long double; template ostream& operator<<(ostream& os, const vector& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ld PI = static_cast(3.1415926535897932384626433832795); constexpr ld EPS = static_cast(1e-8); struct Vec { Vec() : dx{0}, dy{0} {} Vec(const ld dx, const ld dy) : dx{dx}, dy{dy} {} ld dx; ld dy; Vec rotate(const ld theta) const { Vec ans; ans.dx = cosl(theta) * dx - sinl(theta) * dy; ans.dy = sinl(theta) * dx + cosl(theta) * dy; return ans; } Vec operator*(const ld x) const { Vec ans = *this; ans.dx *= x; ans.dy *= x; return ans; } ld norm() const { return hypotl(dx, dy); } void normalize() { const ld n = norm(); dx /= n; dy /= n; } }; ostream& operator<<(ostream& os, const Vec& v) { os << "(" << v.dx << "," << v.dy << ")"; return os; } int main() { int N; cin >> N; for (int q = 0; q < N; q++) { int T; cin >> T; long double p, omega, v, gx, gy; cin >> p >> omega >> v >> gx >> gy; const ld l = hypotl(omega, (ld)(1 + v)); const ld theta = arg(complex{(ld)(1 + v), omega}); Vec g{gx - powl(l, T) * cosl((ld)T * theta), gy - powl(l, T) * sinl((ld)T * theta)}; ld F = 0; for (int i = 0; i < T; i++) { if (l < 1) { F += powl(l, 2 * T - 2 - 2 * i); } else { F += powl(l, 2 * i); } } vector u(T); ld sumation = 0; if (g.norm() < EPS) { for (int i = 0; i < T; i++) { cout << fixed << setprecision(50) << (long double)0 << " " << (long double)0 << endl; } } else { if (omega == 0 and v == -1) { for (int i = 0; i < T; i++) { if (i == T - 1) { u[i] = Vec{gx, gy}; sumation = u[i].norm() * u[i].norm(); } else { u[i] = Vec{}; } cout << fixed << setprecision(50) << (long double)u[i].dx << " " << (long double)u[i].dy << endl; } } else { for (int i = 0; i < T; i++) { const Vec v = g.rotate(theta * (ld)(i + 1 - T)) * (powl(l, T - 1 - i) / F); u[i] = v; sumation += v.norm() * v.norm(); cout << fixed << setprecision(50) << (long double)v.dx << " " << (long double)v.dy << endl; } } } assert(sumation < p); ld X = 1; ld Y = 0; for (int i = 0; i < T; i++) { ld x = X * ((ld)1 + v) - Y * omega + u[i].dx; ld y = Y * ((ld)1 + v) + X * omega + u[i].dy; X = x; Y = y; } const ld err = hypot(X - gx, Y - gy); assert(err <= 0.0001); show(err); } return 0; }