結果

問題 No.2352 Sharpened Knife in Fall
ユーザー 👑 nu50218nu50218
提出日時 2023-06-16 21:48:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 551 ms / 3,000 ms
コード長 1,362 bytes
コンパイル時間 3,528 ms
コンパイル使用メモリ 219,768 KB
実行使用メモリ 5,712 KB
最終ジャッジ日時 2023-09-06 19:19:11
合計ジャッジ時間 18,201 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 510 ms
5,644 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 538 ms
5,600 KB
testcase_07 AC 273 ms
4,632 KB
testcase_08 AC 537 ms
5,584 KB
testcase_09 AC 547 ms
5,592 KB
testcase_10 AC 542 ms
5,680 KB
testcase_11 AC 540 ms
5,680 KB
testcase_12 AC 551 ms
5,596 KB
testcase_13 AC 540 ms
5,712 KB
testcase_14 AC 255 ms
4,756 KB
testcase_15 AC 512 ms
5,648 KB
testcase_16 AC 28 ms
4,380 KB
testcase_17 AC 13 ms
4,380 KB
testcase_18 AC 192 ms
4,532 KB
testcase_19 AC 420 ms
5,644 KB
testcase_20 AC 167 ms
4,384 KB
testcase_21 AC 158 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOCAL
#include <local.hpp>
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2")
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define postprocess(...) ((void)0)
#endif

using namespace std;
using ll = long long;
using ld = long double;

const ld pi = acosl(-1.0l);

inline ld eval(const ld R, const ld theta) {
    return R * R * (pi * (pi - 2.0l * theta) / (2.0l * pi) - cosl(theta) * sinl(theta));
}

inline ld search(const ld R, const ld S) {
    ld imin = 0.0l;
    ld imax = pi / 2.0l;

    for (int _ = 0; _ < 60; _++) {
        ld imid = (imin + imax) / 2.0l;
        (S <= eval(R, imid) ? imin : imax) = imid;
    }

    return (imin + imax) / 2.0l;
}

void solve([[maybe_unused]] int test) {
    ld R;
    int K;
    cin >> R >> K;

    vector<ld> ans;

    for (int i = 0; i < K / 2; i++) {
        ld S = pi * R * R * (ld)(i + 1) / (ld)(K + 1);
        ld theta = search(R, S);
        ans.push_back(R * sinl(theta));
        ans.push_back(-R * sinl(theta));
    }
    if (K % 2) ans.push_back(0);
    sort(ans.begin(), ans.end());

    for (int i = 0; i < K; i++) {
        cout << ans[i] << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }

    postprocess();
}
0