# Archipelago

## 题目描述

Archipelago Ber-Islands consists of $N$ islands that are vertices of equiangular and equilateral $N$-gon. Islands are clockwise numerated. Coordinates of island $N_1$ are $(x_1, y_1)$, and island $N_2$ – $(x_2, y_2)$. Your task is to find coordinates of all $N$ islands.

## 代码

#include <cmath>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

static const double PI = acos(-1);
static const double EPS = 1e-8;
int cmp(double t) { return fabs(t) < EPS ? 0 : t > 0 ? 1 : -1; }

struct Point {
double x, y;
Point(double _x = 0, double _y = 0) : x(_x), y(_y) {}
Point operator + (const Point &p) const { return Point(x + p.x, y + p.y); }
Point operator - (const Point &p) const { return Point(x - p.x, y - p.y); }
Point operator * (const double &a) const { return Point(x * a, y * a); }
Point operator / (const double &a) const { return Point(x / a, y / a); }
double operator ! () const { return sqrt(x * x + y * y); }
double operator & (const Point &p) const { return x * p.x + y * p.y; }
double operator * (const Point &p) const { return x * p.y - y * p.x; }
Point operator << (const double &a) const { return Point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a)); }
};

struct Solver {
private:
static const int N = 160;
int n, a, b;
Point p, q, tmp, ans[N];
void input() { scanf("%d%d%d%lf%lf%lf%lf", &n, &a, &b, &p.x, &p.y, &q.x, &q.y); }
void init() {
if (a > b) swap(a, b), swap(p, q);
double angle = 2 * PI / n * (b - a);
if (cmp(PI - angle)) {
tmp = p + (q - p) / 2 / cos((PI - angle) / 2);
tmp = (tmp - p << (angle - PI) / 2) + p;
} else tmp = p + (q - p) / 2;
}
void process() {
for (int i = 1; i <= n; ++ i)
ans[a] = p, a %= n, ++ a, p = (p - tmp << -2 * PI / n) + tmp;
for (int i = 1; i <= n; ++ i)
printf("%.6lf %.6lf\n", ans[i].x, ans[i].y);
}

public:
void solve() { input(), init(), process(); }
} solver;

int main() {
solver.solve();
return 0;
}


418 I'm a teapot