結果
問題 | No.306 さいたま2008 |
ユーザー |
![]() |
提出日時 | 2020-06-06 01:52:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 1,785 ms |
コンパイル使用メモリ | 195,120 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-14 12:16:55 |
合計ジャッジ時間 | 2,649 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;long double d(long double x1,long double y1,long double x2,long double y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}int main(){long double ax,ay,bx,by;cin >> ax >> ay >> bx >> by;long double l,r;l = min(ay,by);r = max(ay,by);for(int i=0;i<100;i++){long double c1 = l + (r-l)/3.0;long double c2 = l + (r-l)*2.0/3.0;long double f1 = d(ax,ay,0,c1) + d(bx,by,0,c1);long double f2 = d(ax,ay,0,c2) + d(bx,by,0,c2);if(f1 > f2) {l = c1;}else{r = c2;}}cout<<fixed<<setprecision(10) << r << endl;}