Sgu 120
|
120. Archipelago time limit per test: 0.25 sec. memory limit per test: 4096 KB
Archipelago Ber-Islands consists of N islands that are vertices of equiangular and equilateral N-gon. Islands are clockwise numerated. Coordinates of island N1 are (x1, y1), and island N2 – (x2, y2). Your task is to find coordinates of all N islands.
Input In the first line of input there are N, N1 and N2 (3£ N£ 150, 1£ N1,N2£N, N1¹N2) separated by spaces. On the next two lines of input there are coordinates of island N1 and N2 (one pair per line) with accuracy 4 digits after decimal point. Each coordinate is more than -2000000 and less than 2000000.
Output Write N lines with coordinates for every island. Write coordinates in order of island numeration. Write answer with 6 digits after decimal point.
Sample Input 4 1 3 1.0000 0.0000 1.0000 2.0000 Sample Output 1.000000 0.000000 0.000000 1.000000 1.000000 2.000000 2.000000 1.000000
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <set> 7 #include <cstring> 8 #include <iostream> 9 #include <algorithm> 10 using namespace std; 11 #define INF 0x7fffffff 12 #define mod 1000000007 13 #define ll long long 14 #define maxn 2005 15 #define pi acos(-1.0) 16 #define dis(a, b) sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) 17 ll gcd(ll n, ll m){ return m ? gcd(m, n%m) : n; } 18 int n, m, k, c, a, b; 19 struct point{ 20 double x, y; 21 }p[maxn]; 22 int main(){ 23 double tmp, r, t; 24 scanf("%d%d%d", &n,&a, &b); 25 scanf("%lf%lf%lf%lf", &p[a].x,&p[a].y,&p[b].x,&p[b].y); 26 if (a > b)swap(a, b); 27 r = dis(p[a], p[b]) / sin(pi * (b - a) / n) / 2; 28 point o; 29 o.x = (p[a].x + p[b].x) / 2 + (p[b].y - p[a].y) / tan(pi * (b - a) / n) / 2; 30 o.y = (p[a].y + p[b].y) / 2 - (p[b].x - p[a].x) / tan(pi * (b - a) / n) / 2; 31 tmp = asin((p[a].y - o.y)/r); 32 if (p[a].x<o.x)tmp = pi - tmp; 33 for (int i = 1; i <= n; i++){ 34 t = tmp + 2 * pi*(a - i) / n; 35 p[i].x = o.x + r*cos(t); 36 p[i].y = o.y + r*sin(t); 37 } 38 for (int i = 1; i <= n; i++)printf("%.6lf %.6lf\n", p[i].x, p[i].y); 39 return 0; 40 }
|
||||||
|

浙公网安备 33010602011771号