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: Accepted)

#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=3000;
const double MPI=acos(-1.0);
struct P { double x,y; P() {} P(double x,double y):x(x),y(y) {} };

int n,den;
int num[MAXN];


double ang[MAXN-1];


double my_tan(double x) {
  if (x > MPI / 2 - 0.0001) {
    double y = MPI / 2 - x;
    return 1.0 / y - y / 3 - y * y * y / 45;
  }
  return tan(x);
}


P solve() {
	P ret(0,0);
	REP(i,n) {
		P cur(cos(2*MPI*num[i]/den),sin(2*MPI*num[i]/den));
		//printf("%lf %lf\n",cur.x,cur.y);
		REP(j,n-1) ang[j]=2*MPI*((num[(i+1+j)%n]+den-num[i])%den)/den;
		//REP(j,n-1) printf(" %lf",ang[j]); puts("");
		double mlt=0,sum=0;
		REP(j,n-1) {
			mlt+=0.5*(j-my_tan((2*MPI-ang[j])/4)*sum);
			sum+=my_tan(ang[j]/4);
		}
		//printf(" mlt=%lf\n",mlt);
		ret.x+=mlt*cur.x,ret.y+=mlt*cur.y;
	}
	ll cnt=(ll)n*(n-1)*(n-2)/6; ret.x/=cnt,ret.y/=cnt;
	return ret;
}

void run() {
	scanf("%d%d",&n,&den);
	REP(i,n) scanf("%d",&num[i]);
	P ans=solve();
	printf("%.15lf %.15lf\n",ans.x,ans.y);
}

int main() {
	run();
	return 0;
}