結果

問題 No.2352 Sharpened Knife in Fall
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-16 22:33:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 827 ms / 3,000 ms
コード長 1,679 bytes
コンパイル時間 1,063 ms
コンパイル使用メモリ 112,848 KB
実行使用メモリ 5,592 KB
最終ジャッジ日時 2023-09-06 20:53:00
合計ジャッジ時間 18,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 740 ms
5,476 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 816 ms
5,404 KB
testcase_07 AC 406 ms
4,576 KB
testcase_08 AC 827 ms
5,488 KB
testcase_09 AC 818 ms
5,420 KB
testcase_10 AC 814 ms
5,412 KB
testcase_11 AC 825 ms
5,488 KB
testcase_12 AC 821 ms
5,420 KB
testcase_13 AC 822 ms
5,368 KB
testcase_14 AC 388 ms
4,432 KB
testcase_15 AC 771 ms
5,344 KB
testcase_16 AC 41 ms
4,380 KB
testcase_17 AC 20 ms
4,380 KB
testcase_18 AC 296 ms
4,544 KB
testcase_19 AC 649 ms
5,592 KB
testcase_20 AC 252 ms
4,380 KB
testcase_21 AC 242 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

int main(){

    long double R, pi=M_PI, S, T, U;
    int K;
    cin >> R >> K;
    S = pi*R*R / (long double) (K+1);
    vector<long double> v;

    long double l, r, c;

    if (K % 2 == 0){
        K -= 2;
        T = 0;
        l=0, r=pi/2;
        for (int j=0; j<100; j++){
            c = (l+r)/2;
            U = (c + sin(c)*cos(c)) * R * R;
            if (U*2 <= S) l=c;
            else r=c;
        }
        T = (l + sin(l)*cos(l)) * R * R;
        v.push_back(R*sin(l)); v.push_back(-R*sin(l));
        for (int i=0; i<K/2; i++){
            l=0, r=pi/2;
            for (int j=0; j<100; j++){
                c = (l+r)/2;
                U = (c + sin(c)*cos(c)) * R * R - T;
                if (U <= S) l=c;
                else r=c;
            }
            T = (l + sin(l)*cos(l)) * R * R;
            v.push_back(R*sin(l)); v.push_back(-R*sin(l));
        }
    }
    else{
        v.push_back(0);
        T = 0;
        for (int i=0; i<K/2; i++){
            l=0, r=pi/2;
            for (int j=0; j<100; j++){
                c = (l+r)/2;
                U = (c + sin(c)*cos(c)) * R * R - T;
                if (U <= S) l=c;
                else r=c;
            }
            T = (l + sin(l)*cos(l)) * R * R;
            v.push_back(R*sin(l)); v.push_back(-R*sin(l));
        }
    }
    
    sort(v.begin(), v.end());
    for (auto x : v) cout << setprecision(18) << x << endl;

    return 0;
}
0