結果

問題 No.764 浮動点
ユーザー pekempeypekempey
提出日時 2018-12-12 00:37:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 1,500 ms
コード長 1,208 bytes
コンパイル時間 439 ms
コンパイル使用メモリ 39,788 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 22:29:42
合計ジャッジ時間 1,491 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 5 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 6 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 6 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 7 ms
4,348 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 7 ms
4,348 KB
testcase_13 AC 7 ms
4,348 KB
testcase_14 AC 8 ms
4,348 KB
testcase_15 AC 7 ms
4,348 KB
testcase_16 AC 8 ms
4,348 KB
testcase_17 AC 7 ms
4,348 KB
testcase_18 AC 6 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 7 ms
4,348 KB
testcase_21 AC 7 ms
4,348 KB
testcase_22 AC 7 ms
4,348 KB
testcase_23 AC 7 ms
4,348 KB
testcase_24 AC 7 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
    }
}
0