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++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int n;
double sins[200005];
vector<double> iso;

double S(int x, int y){
  return (sins[x] + sins[y] + sins[n-x-y])/2.0;
}

// s以下の面積が何通りとれるか
long cnt(double s){
  long ret = 0;
  // x < y < z が何通りとれるか
  for(int x=1; x<=n/3; x++){
    if(3*x+3>n) break;
    if(S(x, (n-x-1)/2) < s){
      ret += (n-x-1)/2 - x;
      continue;
    }
    if(S(x, x+1) >s){
      continue;
    }
    int ly=x+1, ry=(n-x-1)/2; // lyは必ずs以下と保証される
    while(ry-ly>1){
      int my = (ry+ly)/2;
      if(S(x, my) > s) ry=my;
      else ly=my;
    }
    ret += ly - x;
  }
  ret = ret*n*2; // 始点n通り＊反対周り

  // 正三角形
  if(n%3==0 && s>=S(n/3,n/3)) ret+=n/3;

  // 二等辺三角形
  long ll = upper_bound(all(iso), s) - iso.begin();
  ret += ll*n;

  return ret;
}

int main(){
  long k;
  cin>>n>>k;

  const double p = atan(1)*4.0;
  rep(i,n+1) sins[i] = sin(2.0*p/n*i);

  // 2等辺三角形の面積列挙
  repl(i,1,n-1) if((n-i)%2==0){
    iso.pb(S(i,(n-i)/2));
  }
  sort(all(iso));

  double sl=0, sr=2;
  rep(_,50){
    double sm = (sl+sr)/2.0;
    if(cnt(sm) < k) sl = sm;
    else sr = sm;
  }

  printf("%.11f\n", sr);

  return 0;
}