結果
| 問題 | No.306 さいたま2008 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-09 00:09:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,180 bytes |
| コンパイル時間 | 1,292 ms |
| コンパイル使用メモリ | 161,352 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-02-14 12:15:46 |
| 合計ジャッジ時間 | 2,159 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#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;
long double dist(long double x1, long double y1, long double x2, long double y2){
return (y1-y2)*(y1-y2) + (x1-x2)*(x1-x2);
}
long double solve(long double p){
long double AP = dist(0, p, xa, ya);
long double BP = dist(0, p, xb, yb);
return sqrt(AP) + sqrt(BP);
//return AP + BP;
}
int main(){
cin >> xa >> ya >> xb >> yb;
long double left = -1.0;
long double right = 2000.0;
REP(i,1000){
long double a1 = (2*left + right) / 3;
long double a2 = (left + 2*right) / 3;
long double s1 = solve(a1);
long double s2 = solve(a2);
if(s1 < s2){
right = a2;
}
else if(s2 <= s1){
left = a1;
}
}
printf("%.20Lf\n", left);
return 0;
}