結果
問題 | No.620 ぐるぐるぐるりん |
ユーザー | Pachicobue |
提出日時 | 2017-12-20 20:59:44 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 51 ms / 1,000 ms |
コード長 | 3,512 bytes |
コンパイル時間 | 2,713 ms |
コンパイル使用メモリ | 206,568 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 02:05:59 |
合計ジャッジ時間 | 3,936 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 3 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 3 ms
6,944 KB |
testcase_04 | AC | 3 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 3 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 3 ms
6,944 KB |
testcase_20 | AC | 3 ms
6,944 KB |
testcase_21 | AC | 3 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,944 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 51 ms
6,944 KB |
testcase_27 | AC | 3 ms
6,940 KB |
testcase_28 | AC | 49 ms
6,940 KB |
testcase_29 | AC | 49 ms
6,940 KB |
testcase_30 | AC | 50 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> #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 <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "sz:" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template <typename S, typename T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ld PI = static_cast<ld>(3.1415926535897932384626433832795); constexpr ld EPS = static_cast<ld>(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>{(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<Vec> 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; }