题意:给出两点,求经过这两点的正n边形的最小面积

题解:这两点一定是最长的弦,我们设正多边形中点c,找到c到每个点的距离(都相同)

我们知道那个等腰三角形的底与每个角度就使用余弦定理

#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<vector>
#include<string>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define eps 1E-8
/*注意可能会有输出-0.000*/
#define Sgn(x) (x<-eps? -1 :x<eps? 0:1)//x为两个浮点数差的比较,注意返回整型
#define Cvs(x) (x > 0.0 ? x+eps : x-eps)//浮点数转化
#define zero(x) (((x)>0?(x):-(x))<eps)//判断是否等于0
#define mul(a,b) (a<<b)
#define dir(a,b) (a>>b)
typedef long long ll;
typedef unsigned long long ull;
const int Inf=<<;
const ll INF=1ll<<;
const double Pi=acos(-1.0);
const int Mod=1e9+;
const int Max=;
double Dis(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
double Trg(double dis)
{
double hrep=dis*3.0/;
return sqrt(hrep*dis/*dis/*dis/);
}
int main()
{
int x1,y1,x2,y2;
int n;
while(~scanf("%d %d %d %d %d",&x1,&y1,&x2,&y2,&n))
{
if(!x1&&!y1&&!x2&&!y2&&!n)
break;
double ang,dis;
dis=Dis(x1,y1,x2,y2);
ang=360.0/n*Pi/;
if(n==)
{
printf("%.6f\n",Trg(dis));
}
else if(n&)
{
dis=sqrt(dis*dis/(2.0*(-cos(ang*(n/)))));
printf("%.6f\n",0.5*dis*dis*sin(ang)*n);
}
else
{
dis/=;
printf("%.6f\n",0.5*dis*dis*sin(ang)*n);
}
}
return ;
}

UVA 12300 Smallest Regular Polygon(正多边形)的更多相关文章

  1. uva 12300 - Smallest Regular Polygon

    题意:给定两个点A和B,求包含这两个点的面积最小的正 n(已知)边形. #include<iostream> #include<iomanip> #include<cma ...

  2. hdu6055 Regular polygon 脑洞几何 给定n个坐标(x,y)。x,y都是整数,求有多少个正多边形。因为点都是整数点,所以只可能是正四边形。

    /** 题目:hdu6055 Regular polygon 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6055 题意:给定n个坐标(x,y).x,y都 ...

  3. HDU 6055 17多校 Regular polygon(计算几何)

    Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure ou ...

  4. 2017ACM暑期多校联合训练 - Team 2 1011 HDU 6055 Regular polygon (数学规律)

    题目链接 **Problem Description On a two-dimensional plane, give you n integer points. Your task is to fi ...

  5. 2017 Multi-University Training Contest - Team 2 &hdu 6055 Regular polygon

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  6. HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2

    /* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...

  7. HDU 6055 Regular polygon —— 2017 Multi-University Training 2

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  8. HDU6055 Regular polygon(计算几何)

    Description On a two-dimensional plane, give you n integer points. Your task is to figure out how ma ...

  9. HDU 6055 Regular polygon

    Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

随机推荐

  1. 关于.dll' could not be found 的问题以及解决方案

    最近做项目遇到这个问题,搞了半天,也没有解决. 后台看看了生成的详细信息,提示引用的版本不统一,最后移除,再添加一个相同版本的Mysql.Data.Mysql.Data.Entity.EF6 就解决了 ...

  2. 基础知识(05) -- Java中的类

    Java中的类 1.类的概念 2.类中的封装 3.对象的三大特征 4.对象状态 5.类与类之间的关系 ------------------------------------------------- ...

  3. phpcms 添加memcache支持

    1,修改caches/configs/cache.php <?php return array ( 'file1' => array ( 'type' => 'file', 'deb ...

  4. Android之ListView性能优化——使用ConvertView和ViewHolder

    使用ConvertView和ViewHolder的优化是针对ListView的Adapter(BaseAdapter)的.这种优化的优点如下: 1)重用了ConveertView,在很大程度上减少了内 ...

  5. SQL Server数据库定时自动备份

    SQL Server 数据库定时自动备份[转]   在SQL Server中出于数据安全的考虑,所以需要定期的备份数据库.而备份数据库一般又是在凌晨时间基本没有数据库操作的时候进行,所以我们不可能要求 ...

  6. C++ 共享内存 函数封装

    #pragma once #include <string> #include <wtypes.h> #include <map> using namespace ...

  7. SecureCRT中设置 \n 为回车换行,和 \r\n 的行为一致

    勾上途中红框的选项即可

  8. iOS sqlite数据库图像化查看

    问题描述:在xocde上用sqlite数据库的时候,因为没有图形化界面,有些时候很难看出自己设计的数据库是否有问题,比如我刚上手sqlite数据库设计id为自增长时,很自然的用了identify(1, ...

  9. 《转载》GET,POST,PUT,DELETE的区别

    本文转载自:转载请说明出处,谢谢[hyddd(http://www.cnblogs.com/hyddd/)] Http定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT, ...

  10. 在VisualStudio 编辑器文本替换中使用正则表达式

    替换时使用正则表达式,其优点在于可以通过正则分组捕获,并在替换字符串中使用. 在VS2012之前的版本中,捕获内容用{}包含,引用时,使用 \1 形式: 在VS2012及以后版本中,捕获内容符合正则表 ...