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 Fortran (gfortran v4.8.4) (judge verdict: Wrong Answer)

program incenters
  implicit none
  real(8), parameter :: pi = 3.14159265358979d0
  integer :: n, l, t, i, j, k, m = 0
  real(8) :: v(3000,2) = 0.d0, c(2) = 0.d0, s(0:3000,2) = 0.d0, tmp(2)
  real(8) :: di, dj, dk
  character(48) :: sx, sy
  read(*,*) n, l
  do i = 1, n
    read(*,*) t
    v(i,1) = cos(2.d0*pi*real(t,8)/real(l,8))
    v(i,2) = sin(2.d0*pi*real(t,8)/real(l,8))
    s(i,:) = s(i-1,:)+v(i,:)
  end do
  do i = 1, n-2
    do j = i+1, n-1
      if (m > 1000000) then
        tmp = s(n,:)-s(j,:)
        di = d(v(j,:),tmp/real(n-j,8))
        dj = d(tmp/real(n-j,8),v(i,:))
        dk = d(v(i,:),v(j,:))
        c = c+(real(n-j,8)*(di*v(i,:)+dj*v(j,:))+dk*tmp)/(di+dj+dk)
      else
        do k = j+1, n
          m = m+1
          di = d(v(j,:),v(k,:))
          dj = d(v(k,:),v(i,:))
          dk = d(v(i,:),v(j,:))
          c = c+(di*v(i,:)+dj*v(j,:)+dk*v(k,:))/(di+dj+dk)
        end do
      end if
    end do
  end do
  c = 6.d0*c/(real(n,8)*real(n-1,8)*real(n-2,8))
  write(sx,'(f32.16)') c(1)
  write(sy,'(f32.16)') c(2)
  write(*,'(a,x,a)') trim(adjustl(sx)), trim(adjustl(sy))
contains
  real(8) function d(v1,v2)
    real(8), intent(in) :: v1(2), v2(2)
    d = sqrt(dot_product(v1-v2,v1-v2))
  end
end program incenters