結果

問題 No.1381 Simple Geometry 1
ユーザー umezo
提出日時 2021-02-07 20:57:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 191,752 KB
最終ジャッジ日時 2025-01-18 14:01:36
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

double EPS=1e-9;
double x,y,z,w;
double f(double a){
  return sqrt(a*a+y*y)-w-sqrt(x*x/a/a+z*z);
}

int main(){
  cin>>x>>y>>z>>w;
  
  double l=0,r=1e18;
  rep(i,50){
    double mid=(l+r)/2;
    if(f(mid)>EPS) r=mid;
    else if(f(mid)<EPS) l=mid;
    else break;
  }
  double a=r;
  double ans=x-a*y/2-x*z/2/a-(a-z)*(x/a-y)/2;
  
  cout<<fixed<<setprecision(10)<<ans<<endl;
  
  return 0;
}
0