Language: C++

//geometric-2D library
//--------------------------------------------------------------//
#include<vector>
#include<complex>
#include<cmath>
#include<iostream>
#define eps 1e-9
using namespace std;
typedef complex<double> point;
typedef pair<point, point> line;

double dis(point a, point b);
double dot(point a, point b);
double cross(point a, point b);
int    ccw(point a, point b, point c);
double line_to_point_dis(line l, point p);
double seg_to_point_dis(line l, point p);
double seg_to_seg_dis(line a, line b);
bool   is_cross(line a, line b);
point  cross_point(line a, line b);
pair<point, point> norm(point p);


  //b??????a??????????????????
double dis(point a, point b){
  return abs(a - b);
}

//??????
double dot(point a, point b){
  return a.real()*b.real() + a.imag()*b.imag();
}

//??????
double cross(point a, point b){
  return imag(conj(a) * b);
}

//counter clock wise
int ccw(point a, point b, point c){
  if(cross(b - a, c - a) >  eps)return  1;//??????ab????????´
  if(cross(b - a, c - a) < -eps)return -1;//??????ab????????´
  if(dot(b - a, c - a) < -eps)return 2;//??´???ab??????a???????????????
  if(abs(b - a) + eps < abs(c - a))return -2;//??´???ab??????b???????????????
  return 0;//??´???ab???
}

double line_to_point_dis(line l, point p){
  return abs(cross(p - l.first, l.second - l.first))/
    abs(l.second - l.first);
}

double seg_to_point_dis(line l, point p){
  point a = l.first, b = l.second, c = p;
  if(dot(b - a, c - a) < eps)return abs(c - a);
  if(dot(a - b, c - b) < eps)return abs(c - b);
  return line_to_point_dis(l, p);
}

double seg_to_seg_dis(line a, line b){
  double res = seg_to_point_dis(a, b.first);
  res = min(res, seg_to_point_dis(a, b.second));
  res = min(res, seg_to_point_dis(b, a.first));
  res = min(res, seg_to_point_dis(b, a.second));
  return res;
}

bool is_cross(line a, line b){
  if(ccw(a.first, a.second, b.first) *
     ccw(a.first, a.second, b.second) <= 0 &&
     ccw(b.first, b.second, a.first) *
     ccw(b.first, b.second, a.second) <= 0){
    return true;
  }
  return false;
}

point cross_point(line a, line b){
  double d1 = cross(b.second - b.first,
                    b.first - a.first);
  double d2 = cross(b.second - b.first,
                    a.second - a.first);
  return a.first + (a.second - a.first) * d1/d2;
}

pair<point, point> norm(point p){
  return pair<point, point>(p*point(0, 1),
                            p*point(0, -1));
}

//point a, b, point c, d
point seg_to_seg_cross_point(line a, line c){
  if(not is_cross(a, c)) return point(1e9, 1e9);
  double xa = a.first.real(),  ya = a.first.imag();
  double xb = a.second.real(), yb = a.second.imag();
  double xc = c.first.real(),  yc = c.first.imag();
  double xd = c.second.real(), yd = c.second.imag();
  double s  = (ya - yc)*(xb - xa) + (yb - ya)*(xc - xa);
  double t  = (xb - xa)*(yd - yc) - (xd - xc)*(yb - ya);
  if(abs(t) < eps) return point(1e9, 1e9);
  return c.first + s*(c.second - c.first)/t;
}

int main(){
  int n, k;
  std::cin >> n >> k;
  vector<point> vp(n);
  double theta = 360.0/n * M_PI/180.0;
  for (int i = 0; i < n; i++) {
    vp[i] = point(-sin(i*theta), sin(i*theta));
  }
  double area = cross(vp[0], vp[1])/2;
  point cp = seg_to_seg_cross_point(line(vp[0], vp[k]), line(vp[1], vp[(1-k+n)%n]));
  double dist = seg_to_point_dis(line(vp[0], vp[1]), cp);
  std::cout << fixed << setprecision(12) <<  (area - dist*dis(vp[0], vp[1])/2)*n << std::endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:115:25: error: 'setprecision' was not declared in this scope
  115 |   std::cout << fixed << setprecision(12) <<  (area - dist*dis(vp[0], vp[1])/2)*n << std::endl;
      |                         ^~~~~~~~~~~~
a.cc:7:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
    6 | #include<iostream>
  +++ |+#include <iomanip>
    7 | #define eps 1e-9