結果

問題 No.306 さいたま2008
ユーザー btkbtk
提出日時 2015-11-28 00:17:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 873 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 145,740 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 00:38:48
合計ジャッジ時間 2,229 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,348 KB
testcase_01 AC 6 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 7 ms
4,352 KB
testcase_04 AC 6 ms
4,348 KB
testcase_05 AC 7 ms
4,352 KB
testcase_06 AC 6 ms
4,352 KB
testcase_07 AC 7 ms
4,348 KB
testcase_08 AC 6 ms
4,352 KB
testcase_09 AC 6 ms
4,352 KB
testcase_10 AC 7 ms
4,352 KB
testcase_11 AC 7 ms
4,352 KB
testcase_12 AC 7 ms
4,352 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 7 ms
4,352 KB
testcase_16 AC 6 ms
4,352 KB
testcase_17 AC 6 ms
4,356 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 7 ms
4,352 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 7 ms
4,352 KB
testcase_22 AC 6 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define F __float128
const F eps=1e-20;

F Xa,Xb,Ya,Yb;
inline F sqrt(F x){
    F top=x;
    F bottom=0;
    while(top-bottom>eps){
        F m=(top+bottom)/2;
        if(m*m>x)top=m;
        else bottom=m;
    }
    return bottom;
}

inline F calc(F yy){
    F t=Yb-yy;
    F l=yy-Ya;
    return sqrt(Xb*Xb+t*t)+sqrt(Xa*Xa+l*l);
}
int main() {
    cout<<setprecision(10);
    cout<<fixed;
    double xa,ya,xb,yb;
    cin>>xa>>ya>>xb>>yb;
    if(ya>yb){
        swap(xa,xb);
        swap(ya,yb);
    }
    Xa=xa;
    Ya=ya;
    Xb=xb;
    Yb=yb;
    {
        F top=Yb;
        F bottom=Ya;
        while(top-bottom>eps){
            F m1=(top*2+bottom)/3;
            F m2=(top+bottom*2)/3;
            if(calc(m1)<calc(m2))bottom=m2;
            else top=m1;
        }
        cout<<(double)top<<endl;
    }

    return 0;
}
0