結果
問題 |
No.306 さいたま2008
|
ユーザー |
![]() |
提出日時 | 2016-08-12 00:41:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 723 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 82,056 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-07 11:54:33 |
合計ジャッジ時間 | 1,610 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 2 |
ソースコード
#include <iostream> #include <fstream> #include <vector> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <cmath> using namespace std; double x[2], y[2]; double f(double m) { return sqrt(x[0] * x[0] + (m - y[0]) * (m - y[0])) + sqrt(x[1] * x[1] + (m - y[1]) * (m - y[1])); } template<class Function> double ternarySearch(double l, double r, Function f) { for(int i = 0; i < 200; i++) { double a = (l + l + r) / 3; double b = (l + r + r) / 3; if(f(a) > f(b)) l = a; else r = b; } return l; } int main() { cin.tie(0); ios::sync_with_stdio(false); for(int i = 0; i < 2; i++) { cin >> x[i] >> y[i]; } cout << setprecision(15)<<ternarySearch(0, 1000, f) << endl;; }