結果

問題 No.1319 最強とんがりコーン
ユーザー hotman78
提出日時 2022-01-12 19:22:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 950 bytes
コンパイル時間 1,909 ms
コンパイル使用メモリ 200,196 KB
最終ジャッジ日時 2025-01-27 10:36:27
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 60 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using D=long double;

template<typename F>
D romberg_integration(int m,D a,D b,F f){
    assert(m<=24);
    std::vector<std::vector<D>>data(m,vector<D>(m));
    std::vector<D>h(m);
    h[0]=b-a;
    data[0][0]=(f(a)+f(b))*(b-a)/2;
    for(int i=1;i<m;++i){
        h[i]=h[i-1]/2;
        data[0][i]=data[0][i-1]/2;
        for(int j=0;j<(1<<(i-1));++j){
            data[0][i]+=h[i]*f(a+(2*j+1)*h[i]);
        }
    }
    for(int i=0;i<m-1;++i){
        for(int j=0;j<m-i-1;++j){
            data[i+1][j]=data[i][j+1]+(data[i][j+1]-data[i][j])/(pow(h[j]/h[j+1+i],2)-1);
        }
    }
    return data[m-1][0];
}

int main(){
    cout<<fixed<<setprecision(15);
    D r,h,d;
    cin>>r>>h>>d;
    auto f=[&](D z)->D{
        D r2=r*(h-z)/h;
        D t=acos(d/2/r2);
        if(r2*r2-d*d/4<0)return 0;
        return r2*r2*t-d*sqrt(r2*r2-d*d/4)/2;
    };
    cout<<romberg_integration(12,0,h,f)*2<<endl;
}
0