結果

問題 No.306 さいたま2008
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-07-06 02:23:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,678 bytes
コンパイル時間 1,546 ms
コンパイル使用メモリ 163,232 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 18:28:51
合計ジャッジ時間 2,277 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<typename Func>
double findMinReal(double L, double R, Func f) { //[L, R)
    double l = L, r = R;
    rep(i, 0, 101)
    {
        double m1 = (l * 2.0 + r) / 3.0;
        double m2 = (l + r * 2.0) / 3.0;
        if (f(m1) > f(m2))
            l = m1;
        else
            r = m2;
    }

    return r;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/




double a, b, c, d;
//---------------------------------------------------------------------------------------------------
double f(double x) {
    double d1 = sqrt(a * a + (b - x) * (b - x));
    double d2 = sqrt(c * c + (d - x) * (d - x));
    return d1 + d2;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> a >> b >> c >> d;
    double p = findMinReal(0, 1e9, f);
    printf("%.10f\n", p);
}
0