結果
問題 | No.764 浮動点 |
ユーザー |
|
提出日時 | 2018-12-12 00:37:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,500 ms |
コード長 | 1,208 bytes |
コンパイル時間 | 345 ms |
コンパイル使用メモリ | 40,064 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-24 17:37:26 |
合計ジャッジ時間 | 1,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <stdio.h>#include <math.h>int n;double L[1002];double f(double d, double r1, double r2) {if (r1 < 1e-8 || r2 < 1e-8 || r1 + r2 < d + 1e-8) return 0;if (d + r2 < r1 + 1e-8) return r2*r2*acos(-1);if (d + r1 < r2 + 1e-8) return r1*r1*acos(-1);double A = acos((r1*r1+d*d-r2*r2)/(2*r1*d));double B = acos((r2*r2+d*d-r1*r1)/(2*r2*d));return r1*r1*A-r1*r1*cos(A)*sin(A) + r2*r2*B-r2*r2*cos(B)*sin(B);}int main() {int n;scanf("%d", &n);for (int i = 0; i <= n + 1; i++) {scanf("%lf", L + i);}for (int i = 1; i <= n; i++) {double mxL = 0;double smL = 0;double mxR = 0;double smR = 0;for (int j = 1; j <= i; j++) {mxL = fmax(mxL, L[j]);smL += L[j];}for (int j = i + 1; j <= n + 1; j++) {mxR = fmax(mxR, L[j]);smR += L[j];}double mnL = fmax(0.0, 2*mxL - smL);double mnR = fmax(0.0, 2*mxR - smR);double ans = 0;ans += f(L[0], smL, smR);ans -= f(L[0], smL, mnR);ans -= f(L[0], mnL, smR);ans += f(L[0], mnL, mnR);printf("%.15f\n", ans);}}