1C - Ancient Berland Circus

思路:

  求出三角形外接圆;

  然后找出三角形三条边在小数意义下的最大公约数;

  然后n=pi*2/fgcd;

  求出面积即可;

代码:

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define INF (1e9)
#define eps (1e-4)
#define pi (3.1415926535) struct point
{
double x,y;
};
struct point ai[]; struct line {
double k,b; line *another; void updata(struct point a,struct point bb)
{
another=new line;
if(a.x==bb.x) k=INF,b=a.x;
else
{
if(a.y==bb.y) k=,b=a.y;
else
{
k=(bb.y-a.y)/(bb.x-a.x);
b=a.y-k*a.x;
}
}
if(k==)
{
another->k=INF,another->b=(a.x+bb.x)/2.0;
}
else if(k==INF)
{
another->k=,another->b=(a.y+bb.y)/2.0;
}
else
{
another->k=-1.0/k;
struct point temp;
temp.x=(a.x+bb.x)/2.0;
temp.y=(a.y+bb.y)/2.0;
another->b=temp.y-another->k*temp.x;
}
}
};
struct line bi[],ci[]; struct point getnode(line a,line b)
{
struct point res;
res.x=(b.b-a.b)/(a.k-b.k);
res.y=a.k*res.x+a.b;
return res;
} double dist(struct point a,struct point b)
{
double aa=(a.x-b.x)*(a.x-b.x);
double bb=(a.y-b.y)*(a.y-b.y);
aa=sqrt(aa+bb);
return aa;
} double fgcd(double x, double y) {
while (fabs(x)>eps&&fabs(y)>eps)
{
if (x > y) x-=floor(x/y)*y;
else y-=floor(y/x)*x;
}
return x + y;
} int main()
{
for(int i=;i<=;i++) cin>>ai[i].x>>ai[i].y;
bi[].updata(ai[],ai[]);
bi[].updata(ai[],ai[]);
bi[].updata(ai[],ai[]);
for(int i=;i<=;i++) ci[i]=*bi[i].another;
struct point o=getnode(ci[],ci[]);
double R=dist(o,ai[]);
double vi[];
vi[]=dist(ai[],ai[]);
vi[]=dist(ai[],ai[]);
vi[]=dist(ai[],ai[]);
sort(vi+,vi+);
double an[];
an[]=2.0*asin(vi[]/(2.0*R));
an[]=2.0*asin(vi[]/(2.0*R));
an[]=2.0*pi-an[]-an[];
sort(an+,an+);
double ans1=fgcd(an[],an[]);
double ans2=fgcd(an[],an[]);
double ans=fgcd(max(ans1,ans2),min(ans1,ans2));
double ans_=(2.0*pi-ans)/2.0;
printf("%.9lf",R*R*sin(ans)*pi/ans);
return ;
}

最新文章

  1. javascript操作字符串的方法
  2. (转)大数据时代下的SQL Server第三方负载均衡方案----Moebius测试
  3. linux下cp目录时排除一个或者多个目录的方法
  4. JQuery.Ajax之错误调试帮助信息介绍
  5. appDelegate中的委托协议方法以及使用观察者模式获取其触发方法
  6. IOS-UI-UIDynamic(二)
  7. [React Native] Passing data when changing routes
  8. 为什么手机连接wifi会显示已停用?
  9. bzoj 3669: [Noi2014]魔法森林 动态树
  10. Android项目中包名的改动
  11. Ural 1450 求最长路 SPFA
  12. C++学习笔记(十二):重载函数
  13. NoFragment重大bug
  14. 图解Redis之数据结构篇——简单动态字符串SDS
  15. Terraform:创建 Azure 虚机
  16. docker--命令详解
  17. CentOS 6.5下Squid代理服务器的安装与配置
  18. 题解 UVA10048 【Audiophobia】
  19. linux下查找nginx里的nginx.conf文件地址方法
  20. UML 之 数据流图(DFD)

热门文章

  1. TCP的挥手协议和握手协议2
  2. [剑指Offer] 20.包含min函数的栈
  3. html框架集 target
  4. Impala简介PB级大数据实时查询分析引擎
  5. 【bzoj4750】密码安全 单调栈
  6. SNMP OID Reference - NetScaler 10
  7. 解析Mybaits的insert方法返回数字-2147482646的原因
  8. 洛谷P1282 多米诺骨牌 (DP)
  9. 在xml文件中引入带有@Configuration的Java类
  10. JavaScript 页面间传值