結果
| 問題 | No.1381 Simple Geometry 1 |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-02-08 10:38:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,211 bytes |
| 記録 | |
| コンパイル時間 | 795 ms |
| コンパイル使用メモリ | 93,452 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 06:58:53 |
| 合計ジャッジ時間 | 1,776 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 29 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1381.cc: No.1381 Simple Geometry 1 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int CNT = 1000;
/* typedef */
/* global variables */
/* subroutines */
/* main */
int main() {
double s, ap, cq, w;
scanf("%lf%lf%lf%lf", &s, &ap, &cq, &w);
// let x = |ad|, y = |cd|,
// -> s = x*y, |bp|^2=|ap|^2+y^2, |bq|^2=x^2+|cq|^2
// x >= |ap|, y >= |cq| -> s=x*y>=x*|cq| -> x<=s/|cq|
double ap2 = ap * ap, cq2 = cq * cq;
double x0 = ap, x1 = s / cq;
for (int cnt = 0; cnt < CNT; cnt++) {
double x = (x0 + x1) / 2;
double y = s / x;
double bp = sqrt(ap2 + y * y);
double bq = sqrt(x * x + cq2);
if (bp >= bq + w) x0 = x;
else x1 = x;
}
//printf("x=%lf, y=%lf\n", x0, s / x0);
double y0 = s / x0;
double t = s - (ap * y0 / 2 + x0 * cq / 2 + (x0 - ap) * (y0 - cq) / 2);
printf("%.10lf\n", t);
return 0;
}
tnakao0123