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¹N2separated by spaces. On the next two lines of input there are coordinates of island N1 and N2 (one pair per line) with accuracy 4digits 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 思路:首先旋转N1N2一定角度到圆心方向利用三角形求出圆心O,然后旋转oN1得到其他点
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=150;
const double eps=1e-12;
const double pie=acos(-1);
double xo,yo;
double x[maxn],y[maxn];
int n,n1,n2;
typedef pair<double,double> P;
P rot(double x,double y,double angle){
P p1;
p1.first=y*sin(angle)+x*cos(angle);
p1.second=y*cos(angle)-x*sin(angle);
return p1;
}
int main(){
scanf("%d%d%d",&n,&n1,&n2);n1--;n2--;
scanf("%lf%lf%lf%lf",x+n1,y+n1,x+n2,y+n2);
if(n1>n2)swap(n1,n2);
P p1=P(x[n2]-x[n1],y[n2]-y[n1]);
int gap=n2-n1;
double angle=pie/n*gap;
double angle2=pie/2-angle;if(angle<eps)angle+=pie;//取夹角不可能钝角或<0
p1=rot(p1.first,p1.second,angle2);
p1.first=-p1.first/2/cos(angle2);
p1.second=-p1.second/2/cos(angle2);
xo=-p1.first+x[n1],yo=-p1.second+y[n1];
for(int i=(n1+1)%n;i!=n1;i=(i+1)%n){
p1=rot(p1.first,p1.second,2*pie/n);
x[i]=p1.first+xo;
y[i]=p1.second+yo;
}
for(int i=0;i<n;i++){
printf("%.6f %.6f\n",x[i],y[i]);
}
return 0;
}

  

快速切题 sgu120. Archipelago 计算几何的更多相关文章

  1. 快速切题sgu127. Telephone directory

    127. Telephone directory time limit per test: 0.25 sec. memory limit per test: 4096 KB CIA has decid ...

  2. 快速切题sgu126. Boxes

    126. Boxes time limit per test: 0.25 sec. memory limit per test: 4096 KB There are two boxes. There ...

  3. 快速切题 sgu123. The sum

    123. The sum time limit per test: 0.25 sec. memory limit per test: 4096 KB The Fibonacci sequence of ...

  4. 快速切题 sgu119. Magic Pairs

    119. Magic Pairs time limit per test: 0.5 sec. memory limit per test: 4096 KB “Prove that for any in ...

  5. 快速切题 sgu118. Digital Root 秦九韶公式

    118. Digital Root time limit per test: 0.25 sec. memory limit per test: 4096 KB Let f(n) be a sum of ...

  6. 快速切题 sgu117. Counting 分解质因数

    117. Counting time limit per test: 0.25 sec. memory limit per test: 4096 KB Find amount of numbers f ...

  7. 快速切题 sgu116. Index of super-prime bfs+树思想

    116. Index of super-prime time limit per test: 0.25 sec. memory limit per test: 4096 KB Let P1, P2, ...

  8. 快速切题 sgu115. Calendar 模拟 难度:0

    115. Calendar time limit per test: 0.25 sec. memory limit per test: 4096 KB First year of new millen ...

  9. 快速切题 sgu113 Nearly prime numbers 难度:0

    113. Nearly prime numbers time limit per test: 0.25 sec. memory limit per test: 4096 KB Nearly prime ...

随机推荐

  1. Android学习笔记之 ActionBar

    http://developer.android.com/guide/topics/ui/actionbar.html 1,ActionBar的几种形式 2,使用ActionBar需要Activity ...

  2. Python3基础 __doc__ 单行与多行函数文档

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. luogu4473 BZOJ2143 2011[国家集训队]飞飞侠

    题目戳这里 有问题可以在博客@ 应该还会有人来看吧,嘻嘻 正题: 题目大意: 题目很清楚,就是一个点有一定的范围,会有一定的花费 求三个点中的任意两个点到另一个点的最小花费 (麻麻教育我千万读好题目( ...

  4. 明码|2018年蓝桥杯B组题解析第二题-fishers

    标题:明码 汉字的字形存在于字库中,即便在今天,16点阵的字库也仍然使用广泛. 16点阵的字库把每个汉字看成是16x16个像素信息.并把这些信息记录在字节中. 一个字节可以存储8位信息,用32个字节就 ...

  5. POJ3241 Object Clustering(最小生成树)题解

    题意:求最小生成树第K大的边权值 思路: 如果暴力加边再用Kruskal,边太多会超时.这里用一个算法来减少有效边的加入. 边权值为点间曼哈顿距离,那么每个点的有效加边选择应该是和他最近的4个象限方向 ...

  6. 【打分策略】Elasticsearch打分策略详解与explain手把手计算

    一.目的 一个搜索引擎使用的时候必定需要排序这个模块,一般情况下在不选择按照某一字段排序的情况下,都是按照打分的高低进行一个默认排序的,所以如果正式使用的话,必须对默认排序的打分策略有一个详细的了解才 ...

  7. 51NOD 1087 1 10 100 1000

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1087 暴力大法 #include<bits/stdc++.h> ...

  8. github上不去了

    这几天发现github.com上不去了 可能是由于要杜绝国外的人使用最新的技术??从而屏蔽了吗?

  9. python 插入查找

    def interpolation_search(data,val): low= high=len(data)- print('查找过程中......') : mid=low+int((val-dat ...

  10. python 分数的数学四则运算

    import fractions f1 = fractions.Fraction(, ) f2 = fractions.Fraction(, ) print('{} + {} = {}'.format ...