結果

問題 No.2352 Sharpened Knife in Fall
ユーザー AngrySadEightAngrySadEight
提出日時 2023-03-26 11:42:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 354 ms / 3,000 ms
コード長 1,144 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 93,516 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-19 13:35:18
合計ジャッジ時間 8,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 3 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 290 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 348 ms
4,348 KB
testcase_07 AC 175 ms
4,348 KB
testcase_08 AC 348 ms
4,348 KB
testcase_09 AC 349 ms
4,348 KB
testcase_10 AC 347 ms
4,348 KB
testcase_11 AC 347 ms
4,348 KB
testcase_12 AC 354 ms
4,348 KB
testcase_13 AC 350 ms
4,348 KB
testcase_14 AC 166 ms
4,348 KB
testcase_15 AC 329 ms
4,372 KB
testcase_16 AC 19 ms
4,372 KB
testcase_17 AC 10 ms
4,372 KB
testcase_18 AC 128 ms
4,372 KB
testcase_19 AC 272 ms
4,372 KB
testcase_20 AC 108 ms
4,372 KB
testcase_21 AC 103 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
using namespace std;

double area(double center, double r){
    double theta = acos(center / r);
    double sector = r * r * theta;
    double triangle = center * sqrt(r * r - center * center);
    return sector - triangle;
}

int main(){
    int R,K;
    cin >> R >> K;
    double PI = acos(-1);
    double dr = (double)R;
    double S = dr * dr * PI;
    vector<double> ans(0);
    for (int i = 0; i < K / 2; i++){
        double portion_s = S * (double)(i + 1) / (double)(K + 1);

        double ok = 0;
        double ng = dr;
        for (int j = 0; j < 100; j++){
            double center = (ok + ng) / 2;
            if (area(center, dr) >= portion_s){
                ok = center;
            }
            else{
                ng = center;
            }
        }
        ans.push_back(ok);
    }
    int len = ans.size();
    for (int i = 0; i < len; i++){
        cout << setprecision(13) << ans[i] * -1 << endl;
    }
    if (K % 2 == 1) cout << 0 << endl;
    for (int i = len - 1; i >= 0; i--){
        cout << setprecision(13) << ans[i] << endl;
    }
}
0