結果

問題 No.306 さいたま2008
ユーザー kura197kura197
提出日時 2019-11-09 00:03:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,081 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 165,968 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 03:05:41
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int xa, ya, xb, yb;

double dist(double x1, double y1, double x2, double y2){
    return (y1-y2)*(y1-y2) + (x1-x2)*(x1-x2);
}

double solve(double p){
    double AP = dist(0, p, xa, ya);
    double BP = dist(0, p, xb, yb);
    return sqrt(AP) + sqrt(BP);
}

int main(){
    cin >> xa >> ya >> xb >> yb;

    double left = 0.0;
    double right = 1000.0;
    REP(i,100){
        double a1 = (2*left + right) / 3;
        double a2 = (left + 2*right) / 3;
        double s1 = solve(a1);
        double s2 = solve(a2);
        if(s1 < s2){
            right = a2;
        }
        else if(s2 <= s1){
            left = a1;
        }
    }

    printf("%.10lf\n", left);
    return 0;
}
0