結果
| 問題 |
No.306 さいたま2008
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2016-08-12 00:38:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 705 bytes |
| コンパイル時間 | 893 ms |
| コンパイル使用メモリ | 82,064 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 11:22:13 |
| 合計ジャッジ時間 | 1,713 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 3 |
ソースコード
#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 << ternarySearch(0, 1000, f) << endl;;
}
femto