Smallest Regular Polygon - UVa 12300 几何
来源:互联网 发布:绘图设计软件 编辑:程序博客网 时间:2024/05/18 02:59
Smallest Regular Polygon
Given two different points A and B, your task is to find a regular polygon of n sides, passing through these two points, so that the polygon area is minimized.
Input
There will be at most 100 test cases. Each case contains 5 integers xA, yA, xB, yB, n (0<=xA,yA,xB,yB<=100, 3<=n<=10000), the coordinates of A and B, and the number of sides of the regular polygon. The two points A and B are always different. The last test case is followed by a line with five zeros, which should not be processed.
Output
For each test case, print the smallest area of the regular polygon to six decimal places.
Sample Input
0 0 1 1 41 2 3 4 52 3 4 5 60 0 0 0 0
Output for the Sample Input
1.0000005.2573115.196152
题意:给定两个点,求经过这两个点的正n边形的最小面积。
思路:n为偶数,那么就是对角线最长,n为奇数时,相对最远点的斜对角线最长。
AC代码如下:
#include<cstdio>#include<cstring>#include<cmath>using namespace std;double eps=1e-8;int main(){ int n; double x1,x2,y1,y2,d,r,p,S; while(~scanf("%lf%lf%lf%lf%d",&x1,&y1,&x2,&y2,&n) && n>0) { d=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))/2; if(n&1) { p=M_PI*2*(n-1)/(2*n)/2; r=d/sin(p); } else r=d; p=2*M_PI/n; S=r*r*sin(p)/2*n; printf("%.6f\n",S); }}
0 0
- Smallest Regular Polygon - UVa 12300 几何
- UVA 12300 - Smallest Regular Polygon(计算几何)
- uva 12300 - Smallest Regular Polygon(几何)
- uva 12300 Smallest Regular Polygon(计算几何)
- uva 12300 - Smallest Regular Polygon
- 注意精度问题 UVA 12300 Smallest Regular Polygon
- UVa 12300 Smallest Regular Polygon 正多边形内的计算
- Regular Polygon - UVa 10824 几何+二分
- Regular Polygon - UVa 10824 几何暴力
- UVA12300-Smallest Regular Polygon
- UVA 12300 || Smallest Regular Polygon(给定两点,求穿过两点的最小正多边形
- Regular polygon 数学几何
- HDU 6055 Regular polygon【几何】
- 【几何】hdu 6055 Regular polygon
- 【二分+计算几何】hdu 4033 Regular Polygon
- hdu6055 Regular polygon【思维+几何基础】
- HDU 6055 Regular polygon(几何)
- hdu6055 Regular polygon(简单计算几何)
- 如何在SpringMVC中获取request对象
- cocos2d-x 字体描边CCRenderTexture glBlendFunc
- Intent传递非基本类型的值
- 关于Redis的常识
- LeetCode100——Same Tree
- Smallest Regular Polygon - UVa 12300 几何
- 基于OAUTH的电子商务支付集成研究与实现
- Python-MySQL-2
- python之公共方法---日志
- 4 Sum
- apt和dpkg 详解
- 使用nginx+nginx-rtmp-module+ffmpeg搭建流媒体服务器笔记(四)
- 初步感受一下非阻塞的socket
- Myeclipse 10 for mac 安装过程及myeclipse 10 for mac 破解版下载