結果

問題 No.2352 Sharpened Knife in Fall
ユーザー erbowlerbowl
提出日時 2023-06-19 20:21:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,371 ms / 3,000 ms
コード長 2,361 bytes
コンパイル時間 1,889 ms
コンパイル使用メモリ 205,868 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 15:37:11
合計ジャッジ時間 38,547 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2,284 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2,371 ms
4,380 KB
testcase_07 AC 1,183 ms
4,380 KB
testcase_08 AC 2,367 ms
4,376 KB
testcase_09 AC 2,365 ms
4,384 KB
testcase_10 AC 2,367 ms
4,380 KB
testcase_11 AC 2,369 ms
4,376 KB
testcase_12 AC 2,368 ms
4,380 KB
testcase_13 AC 2,370 ms
4,376 KB
testcase_14 AC 1,120 ms
4,376 KB
testcase_15 AC 2,235 ms
4,376 KB
testcase_16 AC 115 ms
4,376 KB
testcase_17 AC 53 ms
4,380 KB
testcase_18 AC 851 ms
4,380 KB
testcase_19 AC 1,860 ms
4,380 KB
testcase_20 AC 729 ms
4,380 KB
testcase_21 AC 692 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;

#include <bits/stdc++.h>
using namespace std;
#define int long long

ll isqrt(ll N){
   ll sqrtN=sqrt(N)-1;
   while(sqrtN+1<=N/(sqrtN+1))sqrtN++;
   return sqrtN;
}


// Union-Find
struct UnionFind {
    // core member
    vector<int> par;

    // constructor
    UnionFind() { }
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    // core methods
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
    
    // debug
    friend ostream& operator << (ostream &s, UnionFind uf) {
        map<int, vector<int>> groups;
        for (int i = 0; i < uf.par.size(); ++i) {
            int r = uf.root(i);
            groups[r].push_back(i);
        }
        for (const auto &it : groups) {
            s << "group: ";
            for (auto v : it.second) s << v << " ";
            s << endl;
        }
        return s;
    }
};


const double PI=3.14159265358979323846;
signed main(){
    ll r,k;
    std::cin >> r>>k;
    // k+1
    ld R;
    R=r;

    for (int i = 0; i < k; i++) {
        ld target = R*R*PI/ld(k+1)*ld(i+1);
        ld l,r;
        l = 0;
        r = PI;
        ll cnt = 100;
        while(cnt){
            cnt--;
            
            ld m = (l+r)/2.0;
            ld sum;
            if(m<PI/2.0){
                sum= PI*R*R*2*m/(2*PI)-R*R*sinl(m)*cosl(m);
            }else{
                sum= PI*R*R*2*m/(2*PI)+R*R*sinl(PI-m)*cosl(PI-m);
            }
            
            // std::cout << m<<" "<<sum<<" "<<target << std::endl;
            if(sum<=target){
                l = m;
            }else{
                r = m;
            }
        }
        if(k%2==1){
            if(i==k/2){
                std::cout << 0 << std::endl;
                continue;
            }
        }
        // std::cout << target<<" "<<l << std::endl;
        std::cout << setprecision(20)<<-cosl(l)*R << std::endl;
    }
}


0