結果

問題 No.620 ぐるぐるぐるりん
ユーザー PachicobuePachicobue
提出日時 2017-12-20 21:03:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 1,000 ms
コード長 1,946 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 200,684 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 21:28:36
合計ジャッジ時間 3,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 38 ms
4,380 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 38 ms
4,380 KB
testcase_29 AC 38 ms
4,376 KB
testcase_30 AC 39 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ld = long double;

constexpr ld PI = static_cast<ld>(3.1415926535897932384626433832795);

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);
    }
};

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;
        if (omega == 0 and v == -1) {
            for (int i = 0; i < T; i++) {
                if (i == T - 1) {
                    cout << fixed << setprecision(40) << gx << " " << gy << endl;
                } else {
                    cout << fixed << setprecision(40) << 0 << " " << 0 << endl;
                }
            }
        } else {
            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);
                }
            }
            for (int i = 0; i < T; i++) {
                const Vec v = g.rotate(theta * (ld)(i + 1 - T)) * (powl(l, T - 1 - i) / F);
                cout << fixed << setprecision(40) << (long double)v.dx << " " << (long double)v.dy << endl;
            }
        }
    }
    return 0;
}

0