結果

問題 No.2352 Sharpened Knife in Fall
ユーザー milanis48663220milanis48663220
提出日時 2023-06-16 21:55:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 3,000 ms
コード長 2,039 bytes
コンパイル時間 1,086 ms
コンパイル使用メモリ 120,440 KB
実行使用メモリ 5,840 KB
最終ジャッジ日時 2023-09-06 19:36:21
合計ジャッジ時間 9,347 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 156 ms
4,816 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 211 ms
5,004 KB
testcase_07 AC 110 ms
4,384 KB
testcase_08 AC 210 ms
5,000 KB
testcase_09 AC 214 ms
5,644 KB
testcase_10 AC 208 ms
4,832 KB
testcase_11 AC 217 ms
4,848 KB
testcase_12 AC 208 ms
4,788 KB
testcase_13 AC 216 ms
4,884 KB
testcase_14 AC 103 ms
4,384 KB
testcase_15 AC 201 ms
5,840 KB
testcase_16 AC 12 ms
4,384 KB
testcase_17 AC 6 ms
4,384 KB
testcase_18 AC 76 ms
4,384 KB
testcase_19 AC 176 ms
5,184 KB
testcase_20 AC 71 ms
4,444 KB
testcase_21 AC 66 ms
4,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int r, k; cin >> r >> k; k++;
    double area = (double)r*(double)r*M_PI;
    int mx = (k-1)/2;
    vector<double> v;
    for(int x = 1; x <= mx; x++){
        auto f = [&](double h){
            double theta = acos(h/r);
            double s = theta*r*r - h*r*sin(theta);
            return s >= ((area/k)*x);
        };
        double rh = r, lh = 0;
        int iter = 50;
        while(iter--){
            double h = (lh+rh)/2;
            if(f(h)){
                lh = h;
            }else{
                rh = h;
            }
        }
        v.push_back(lh);
    }
    vector<double> ans = v;
    if(k%2 == 0) ans.push_back(0);
    reverse(v.begin(), v.end());
    for(double x: v) ans.push_back(-x);
    for(double x: ans) cout << -x << '\n';
}
0