Problem:
Score : 1000 points

Problem Statement

Given are N points on the circumference of a circle centered at (0,0) in an xy-plane.
The coordinates of the i-th point are (\cos(\frac{2\pi T_i}{L}),\sin(\frac{2\pi T_i}{L})).

Three distinct points will be chosen uniformly at random from these N points.
Find the expected x- and y-coordinates of the center of the circle inscribed in the triangle formed by the chosen points.

Constraints

3 \leq N \leq 3000

N \leq L \leq 10^9

0 \leq T_i \leq L-1

T_i<T_{i+1}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N L
T_1
:
T_N

Output

Print the expected x- and y-coordinates of the center of the circle inscribed in the triangle formed by the chosen points.
Your output will be considered correct when the absolute or relative error is at most 10^{-9}.

Sample Input 1

3 4
0
1
3

Sample Output 1

0.414213562373095 -0.000000000000000

The three points have the coordinates (1,0), (0,1), and (0,-1). The center of the circle inscribed in the triangle formed by these points is (\sqrt{2}-1,0).

Sample Input 2

4 8
1
3
5
6

Sample Output 2

-0.229401949926902 -0.153281482438188

Sample Input 3

10 100
2
11
35
42
54
69
89
91
93
99

Sample Output 3

0.352886583546338 -0.109065017701873

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

#define double long double
const double PI = acos(-1);

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	int N; cin >> N;
	int L; cin >> L;
	vector<int> T(N); rep(i, 0, N) {
		cin >> T[i];
	}
	double ansx = 0, ansy = 0;
	int c = 0;
	rep(i, 0, N)rep(j, i + 1, N) {
		double at1 = (T[i] + T[j]) / 2.0;
		double at2 = (T[i] + L + T[j]) / 2.0;
		int c1 = N + i - j - 1;
		int c2 = j - i - 1;
		dump(i, j, T[i], T[j]);
		dump(at1, at2);
		dump(c1, c2);
		ansx += cos(2 * PI * at1 / L) * c1 + cos(2 * PI * at2 / L) * c2;
		ansy += sin(2 * PI * at1 / L) * c1 + sin(2 * PI * at2 / L) * c2;
		c += c1 + c2;
	}
	c /= 3;
	dump(c);
	dump(N * (N - 1) * (N - 2) / 3 / 2);
	assert(c == N * (N - 1) * (N - 2) / 3 / 2);
	c = N * (N - 1) * (N - 2) / 3 / 2;
	dump(ansx, ansy);
	dump(c);
	ansx /= c;
	ansy /= c;
	cout << ansx << " " << ansy << endl;
	return 0;
}