Incenters

· · 题解

Incenters

题意

题解

对于 \triangle ABC,取 AB,BC,CA 弧的中点 D,E,F,可以发现 \triangle DEF 的垂心就是 \triangle ABC 的内心。

考虑如何求 \triangle DEF 的垂心,根据欧拉线,由于 \triangle DEF 的外心为 O(0,0),重心为 \frac{D+E+F}{3},所以垂心为 D+E+F。

于是显然可以 \mathcal O(n^2) 枚举求答案。

代码

const int N = 3e3 + 7;
const ld PI = acos(-1);
int n, L, a[N];
ld x, y;

int main() {
    rd(n, L), rda(a, n);
    for (int i = 1; i < n; i++)
        for (int j = i + 1; j <= n; j++)
            x += (n - 2 * (j - i)) * cos(PI * (a[i] + a[j]) / L),
            y += (n - 2 * (j - i)) * sin(PI * (a[i] + a[j]) / L);
    ll k = 1ll * n * (n - 1) * (n - 2) / 6;
    printf("%.20Lf %.20Lf\n", x / k, y / k);
    return 0;
}