結果

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

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ld = double;
using P = pair<ld, ld>;

inline P mul(const P& p1, const P& p2)
{
    return make_pair(p1.first * p2.first - p1.second * p2.second, p1.second * p2.first + p1.first * p2.second);
}
P power(const P& p, const int n)
{
    if (n == 0) {
        return make_pair(1, 0);
    }
    if (n % 2 == 1) {
        return mul(power(p, n - 1), p);
    } else {
        const P prev = power(p, n / 2);
        return mul(prev, prev);
    }
}

int main()
{
    int N;
    cin >> N;
    for (int q = 0; q < N; q++) {
        int T;
        cin >> T;
        ld p, omega, v, gx, gy;
        cin >> p >> omega >> v >> gx >> gy;
        P A = make_pair(1 + v, omega);
        const P gp = power(A, T);
        gx -= gp.first;
        gy -= gp.second;
        const ld l = hypot(1 + v, omega);
        const ld F = (l == 1 ? T : (pow(l, 2 * T) - 1) / (l * l - 1));
        gx /= F;
        gy /= F;
        vector<P> ans(T, make_pair(gx, gy));
        for (int i = T - 2; i >= 0; i--) {
            ans[i] = make_pair(ans[i + 1].first * (1 + v) + ans[i + 1].second * omega, -ans[i + 1].first * omega + ans[i + 1].second * (1 + v));
        }
        for (int i = 0; i < T; i++) {
            cout << fixed << setprecision(50) << ans[i].first << " " << ans[i].second << endl;
        }
    }
    return 0;
}
0