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. TCP客户端【TcpClient】

    一.阻塞模式 1.命名空间 System.Net.Sockets 2.对象声明 TcpClient dpu1TcpClient = null;//dpu1tcp客户端,TcpClient模式 Netw ...

  2. AD快捷键

    * 在PCB电气层之间切换.在布线的过程中,按此键则换层并自动添加过孔并换层. Q 在公制和英制之间切换 J+C 定位到指定的元件处.在弹出的对话框内输入该元件的编号. G+G 设定栅格吸附尺寸. T ...

  3. object Add(object Before, object After, object Count, object Type);

    [表达式] .Add(Before, After, Count, Type) [表达式] 一个代表 Sheets 对象的变量. Before指定工作表的对象,新建的工作表将置于此工作表之前. Afte ...

  4. gulp报错插件gulp-notify 配置项

    var notify = require("gulp-notify"); module.exports = function(){ var args = Array.prototy ...

  5. Window下Latex加速编译方法以及西农毕设论文模板推荐

    近些日子用Latex写了一遍文章,一共有11页,但是在window下编译需要2分多的时间,使用的是xeletex编译器. 经过查找,得到了以下方法: 如果坚持使用windows下的latex,使用以下 ...

  6. 基于MySQl的分页显示

    <%@page import="java.sql.DriverManager"%> <%@page import="java.sql.ResultSet ...

  7. hdu 5144 NPY and shot 物理+三分

    NPY and shot Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  8. 机器学习 MLIA学习笔记(二)之 KNN算法(一)原理入门实例

    KNN=K-Nearest Neighbour 原理:我们取前K个相似的数据(排序过的)中概率最大的种类,作为预测的种类.通常,K不会大于20. 下边是一个简单的实例,具体的含义在注释中: impor ...

  9. Springboot 编码规范

    1.规范的意义和作用 编码规范可以最大限度的提高团队开发的合作效率 编码规范可以尽可能的减少一个软件的维护成本 , 并且几乎没有任何一个软件,在其整个生命周期中,均由最初的开发人员来维护 编码规范可以 ...

  10. pip 安装pandas报UnicodeDecodeError: 'ascii' codec can't decode byte 0xd5错

    当Python在window环境中通过pip安装pandas报标题这样的错,主要是因为python默认编码格式是:ascii 在https://www.python.org/dev/peps/pep- ...