結果

問題 No.306 さいたま2008
ユーザー kura197kura197
提出日時 2019-11-09 00:07:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,104 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 164,900 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 05:47:00
合計ジャッジ時間 2,216 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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);
    return AP + BP;
}

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

    double left = 0.0;
    double right = 1000.0;
    REP(i,1000){
        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("%.20lf\n", left);
    return 0;
}
0