Problem:
Max Score: $850$ Points

Problem statement

There is a circle which radius is 1.

There are $N$ vertices on the circle's circumference.

The vertices divides into $N$ equal parts over the circumference.

You can choose $3$ distinct vertices, and you can make a triangle.

There are $\frac{N(N - 1)(N - 2)}{6}$ ways choosing vertices.
The question is: Calculate the area of $K$-th smallest triangle in $\frac{N(N-1)(N-2)}{6}$ triangles.

If the area is same, you can order in any order.

If $N = 4, K = 3$, the result is following:

If you select vertices $1$, $2$, and $3$, the area of triangle $= 1$.

If you select vertices $1$, $2$, and $4$, the area of triangle $= 1$.

If you select vertices $1$, $3$, and $4$, the area of triangle $= 1$.

If you select vertices $2$, $3$, and $4$, the area of triangle $= 1$.

As a result, the 3rd smallest triangle's area $= 1$.

Input

The input is given from Standard Input in the following format:

$N \ K$

Output

Please output the $K$-th triangle area.

Print a floating number denoting the answer. The relative or absolute error of your answer should not be higher than $10^{−9}$.

Constraints

$3 \le N \le 200,000$

$1 \le K \le \frac{N(N-1)(N-2)}{6}$

Subtasks

Subtask 1 [ $160$ points ]

$N \le 100$

Subtask 2 [ $240$ points ]

$N \le 1000$

Subtask 3 [ $450$ points ]

$N \le 200,000$

Sample Input 1

4 3

Sample Output 1

1.0000000000000

This example is already explained in the problem statement.

Sample Input 2

6 9

Sample Output 2

0.86602540378

There are $6$ ways to choose a triangle which area is $\frac{\sqrt{3}}{4}$.

There are $10$ ways to choose a triangle which area is $\frac{\sqrt{3}}{2}$.

There are $2$ ways to choose a triangle which area is $\frac{3 \sqrt{3}}{4}$.

Therefore, the 9th smallest triangle's area is $\frac{\sqrt{3}}{2}$.

Sample Input 3

12 220

Sample Output 3

1.29903810568

Writer: E869120

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

#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

int64 calc(double t,int a,double *ss,int n){
  if(3*a==n){
    return 2*ss[a]*ss[a]*ss[a]<=t?n/3:0;
  }
  int64 res=0;
  if(2*ss[a]*ss[a]*ss[n-2*a]>t) return 0;
  res+=n;//a,a,n-2a
  int l=a;
  int r=(n-a)/2;
  if(2*ss[a]*ss[r]*ss[n-a-r]<=t){
    res+=2*n*(r-a);
    if((n-a)%2==0) res-=n;//a,r,r
    return res;
  }
  while(l+1<r){
    int m=(l+r)/2;
    if(2*ss[a]*ss[m]*ss[n-a-m]<=t){
      l=m;
    } else {
      r=m;
    }
  }
  res+=2*n*(l-a);
  return res;
}

void run(void){
  int64 n,k;
  scanf("%lld%lld",&n,&k);
  double *ss=(double *)malloc(sizeof(double)*n);
  int i;
  for(i=0;i<n;i++){
    ss[i]=sin(i*M_PI/n);
  }
  double l=0;
  double r=3*sqrt(3)/4;
  for(i=0;i<200;i++){
    double mid=(l+r)/2;
    int64 cnt=0;
    int j;
    for(j=1;j<=n/3;j++){
      cnt+=calc(mid,j,ss,n);
    }
    if(cnt<=k){
      l=mid;
    } else {
      r=mid;
    }
  }
  printf("%.9lf\n",l);
  return;
}

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