sgu120
来源:互联网 发布:刘道成 mysql 百度云 编辑:程序博客网 时间:2024/05/21 07:54
题目
</pre><p><table width="95%" style="font-family: Simsun;"><tbody><tr><td style="font-size: 9pt;"><h3><strong></strong><p align="CENTER">120. Archipelago</p></h3><p align="CENTER">time limit per test: 0.25 sec. memory limit per test: 4096 KB</p><p align="JUSTIFY"></p><p align="JUSTIFY">Archipelago Ber-Islands consists of <em>N</em> islands that are vertices of equiangular and equilateral <em>N</em>-gon. Islands are clockwise numerated. Coordinates of island <em>N<sub>1</sub></em> are <em>(x<sub>1</sub>, y<sub>1</sub>)</em>, and island <em>N<sub>2</sub></em> – <em>(x<sub>2</sub>, y<sub>2</sub>)</em>. Your task is to find coordinates of all <em>N</em> islands.</p><p align="JUSTIFY"></p><strong></strong><p align="JUSTIFY">Input</p><p align="JUSTIFY">In the first line of input there are <em>N, N<sub>1</sub></em> and <em>N<sub>2</sub> (3<span style="font-family:Symbol;">£</span> N<span style="font-family:Symbol;">£</span> 150, 1<span style="font-family:Symbol;">£</span> N<sub>1</sub>,N<sub>2</sub><span style="font-family:Symbol;">£</span>N, N<sub>1</sub><span style="font-family:Symbol;">¹</span>N<sub>2</sub>) </em>separated by spaces. On the next two lines of input there are coordinates of island <em>N<sub>1</sub></em> and <em>N<sub>2</sub></em> (one pair per line) with accuracy <em>4</em> digits after decimal point. Each coordinate is more than <em>-2000000</em> and less than <em>2000000</em>.</p><p align="JUSTIFY"></p><strong></strong><p align="JUSTIFY">Output</p><p align="JUSTIFY">Write <em>N</em> lines with coordinates for every island. Write coordinates in order of island numeration. Write answer with 6 digits after decimal point.</p><p align="JUSTIFY"></p><p align="JUSTIFY">Sample Input</p><span style="font-family:Courier New;"></span><pre>4 1 31.0000 0.00001.0000 2.0000
Sample Output
1.000000 0.0000000.000000 1.0000001.000000 2.0000002.000000 1.000000
Author: Michael R. MirzayanovResource: PhTL #1 Training ContestsDate: Fall 2001
题解:
通过两个顶点坐标求出正多边形的中点坐标,在求出其外接圆半径,然后三角函数反三角函数各种虐就可以得到每一个点的坐标。。。
代码:
#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#define dis(a, b) sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y))#define pai 3.1415926535897932384626using namespace std;struct point{double x, y;}v[155], now, mid, o;int n, a, b;double drt, r, pai;int main(){scanf("%d%d%d", &n, &a, &b);scanf("%lf%lf%lf%lf", &v[a].x, &v[a].y, &v[b].x, &v[b].y);if (a > b) swap(a, b);mid.x = (v[a].x + v[b].x) / 2;mid.y = (v[a].y + v[b].y) / 2;r = dis(v[a], v[b]) / sin(pai * (b - a) / n) / 2;o.x = mid.x + (v[b].y - v[a].y) / tan(pai * (b - a) / n) / 2;o.y = mid.y - (v[b].x - v[a].x) / tan(pai * (b - a) / n) / 2;pai = asin((v[a].y - o.y) / r);if (acos((v[a].x - o.x) / r) > pai / 2)if (pai >= -1e10) pai = pai - pai;else pai = -pai - pai;for (int i = 1; i <= n; i++)if (i != a && i != b){drt = pai + 2 * pai * (a - i) / n;v[i].x = o.x + r * cos(drt);v[i].y = o.y + r * sin(drt);}for (int i = 1; i <= n; i++) printf("%.6lf %.6lf\n", v[i].x, v[i].y);return 0;}
0 0
- sgu120
- sgu120
- sgu120:Arhipelago
- SGU120 Archipelago
- [SGU120] Archipelago && 计算几何
- IOS开发笔记之绘图(CGContext小记)
- oj3
- Foundation框架基础 NSSet
- android sqlite简单的sql语句介绍
- CentOS 7.0安装LAMP服务器(Apache+PHP+Mysql/MariaDB)
- sgu120
- Video Bitrate Vs. Frame Rate
- 在线查看Android源码
- oj4
- 彻底删除oracle数据库
- 文档对象模型DOM
- java虚拟机学习
- Get started with lxc.
- Foundation框架基础 常用的结构体