結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,812 KB
testcase_01 AC 5 ms
6,944 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 6 ms
6,940 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 5 ms
6,940 KB
testcase_08 AC 5 ms
6,944 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 5 ms
6,940 KB
testcase_14 AC 5 ms
6,944 KB
testcase_15 AC 5 ms
6,940 KB
testcase_16 AC 5 ms
6,940 KB
testcase_17 AC 5 ms
6,944 KB
testcase_18 AC 5 ms
6,948 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 6 ms
6,940 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(); }
//---------------------------------------------------------------------------------------------------
const double EPS = 1e-9;
template<typename Func>
double findMinReal(double L, double R, Func f) { //[L, R)
    double left = L, right = R;

    for (int loop = 0; loop < 101010; ++loop) {
        if (f((left * 2 + right) / 3) <= f((left + right * 2) / 3)) {
            right = (left + right * 2) / 3;
        }
        else {
            left = (left * 2 + right) / 3;
        }
    }
    return (right + left) * 0.5;
}
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  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, 1e4, f);
    printf("%.10f\n", p);
}
0