CodeForces - 1C:Ancient Berland Circus (几何)
Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.
In Ancient Berland arenas in circuses were shaped as a regular (equiangular) polygon, the size and the number of angles could vary from one circus to another. In each corner of the arena there was a special pillar, and the rope strung between the pillars marked the arena edges.
Recently the scientists from Berland have discovered the remains of the ancient circus arena. They found only three pillars, the others were destroyed by the time.
You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.
Input
The input file consists of three lines, each of them contains a pair of numbers –– coordinates of the pillar. Any coordinate doesn't exceed 1000 by absolute value, and is given with at most six digits after decimal point.
Output
Output the smallest possible area of the ancient arena. This number should be accurate to at least 6 digits after the decimal point. It's guaranteed that the number of angles in the optimal polygon is not larger than 100.
Examples
0.000000 0.000000
1.000000 1.000000
0.000000 1.000000
1.00000000
题意:有一个正多边形,现在我们只知道其中3个点的坐标,求原多边形的面积,如果有多个满足,求最小面积。
思路:已知三点,我们可以确定外接圆,然后显然,我们需要多边形的边长最大(或者对于的圆心角最大),但是由于有钝角或者锐角,求最大边长可能要讨论。所以我们求最大圆心角。
可能推论:最大圆心角=三角形的三条边对应的圆心角的gcd。然后就得到了有2pi/gcd边。blabla。
(得到三个角的时候,第三个角=2pi-A-B。而直接求会WA。。。
#include<bits/stdc++.h>
using namespace std;
const double eps=1e-;
const double pi=acos(-1.0);
double Gcd(double a,double b)
{
while(fabs(a)>eps&&fabs(b)>eps){
if(a>b) a-=floor(a/b)*b;
else b-=floor(b/a)*a;
}
return a+b;
}
double x[],y[],L1,L2,L3,S,R;
double dist(int a,int b){
return sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]));
}
double area(){
double p=(L1+L2+L3)/2.0; return sqrt(p*(p-L1)*(p-L2)*(p-L3));
}
int main()
{
for(int i=;i<=;i++) scanf("%lf%lf",&x[i],&y[i]);
L1=dist(,); L2=dist(,); L3=dist(,);
S=area(); R=L1*L2*L3/(S*);
double A=acos((R*R+R*R-L3*L3)/(*R*R));
double B=acos((R*R+R*R-L2*L2)/(*R*R));
double C=*pi-A-B;
double ang=Gcd(Gcd(A,B),C);
double ans=pi/ang*R*R*sin(ang);
printf("%.6lf\n",ans);
return ;
}
CodeForces - 1C:Ancient Berland Circus (几何)的更多相关文章
- Codeforces 1C Ancient Berland Circus
传送门 题意 给出一正多边形三顶点的坐标,求此正多边形的面积最小值. 分析 为了叙述方便,定义正多边形的单位圆心角u为正多边形的某条边对其外接圆的圆心角(即外接圆的某条弦所对的圆心角). (1)多边形 ...
- codforces 1C Ancient Berland Circus(几何)
题意 给出正多边形上三个点的坐标,求正多边形的最小面积 分析 先用三边长求出外接圆半径(海伦公式),再求出三边长对应的角度,再求出三个角度的gcd,最后答案即为\(S*2π/gcd\),S为gcd对应 ...
- cf------(round)#1 C. Ancient Berland Circus(几何)
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...
- AC日记——codeforces Ancient Berland Circus 1c
1C - Ancient Berland Circus 思路: 求出三角形外接圆: 然后找出三角形三条边在小数意义下的最大公约数; 然后n=pi*2/fgcd; 求出面积即可: 代码: #includ ...
- Codeforces Beta Round #1 C. Ancient Berland Circus 计算几何
C. Ancient Berland Circus 题目连接: http://www.codeforces.com/contest/1/problem/C Description Nowadays a ...
- C. Ancient Berland Circus(三点确定最小多边形)
题目链接:https://codeforces.com/problemset/problem/1/C 题意:对于一个正多边形,只给出了其中三点的坐标,求这个多边形可能的最小面积,给出的三个点一定能够组 ...
- 「CF1C Ancient Berland Circus」
CF第一场比赛的最后一题居然是计算几何. 这道题的考点也是比较多,所以来写一篇题解. 前置芝士 平面直角坐标系中两点距离公式:\(l=\sqrt{(X_1-X_2)^2+(Y_1-Y_2)^2}\) ...
- Codeforces 1 C. Ancient Berland Circus-几何数学题+浮点数求gcd ( Codeforces Beta Round #1)
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...
- codeforces 1C (非原创)
C. Ancient Berland Circus time limit per test 2 seconds memory limit per test 64 megabytes input sta ...
随机推荐
- SVM支持向量机
支持向量机(Support Vector Machine,SVM)是效果最好的分类算法之中的一个. 一.线性分类器: 一个线性分类器就是要在n维的数据空间中找到一个超平面,通过这个超平面能够把两类数据 ...
- Unity框架入门
介绍Unity框架之前,先要说几个概念DIP依赖倒置原则.IOC控制反转.DI依赖注入 DIP是设计原则之一,定义:上层不应该依赖于底层,两者都依赖于抽象: 抽象不依赖于细节,细节应该依赖于抽象. 像 ...
- CAFFE学习笔记(二)Caffe_Example之测试mnist
这一次的博客将接着上一次的内容,简单讲解一下如何使用训练后的网络lenet_iter_5000.caffemodel与lenet_iter_10000.caffemodel. 1.在网络训练完毕后,将 ...
- 4 Values whose Sum is 0(二分)
4 Values whose Sum is 0 Time Limit: 15000MS Memory Limit: 228000K Total Submissions: 21370 Accep ...
- Watering Grass(贪心)
Watering Grass n sprinklers are installed in a horizontal strip of grass l meters long and w meters ...
- wcf利用IDispatchMessageInspector实现接口监控日志记录和并发限流
一般对于提供出来的接口,虽然知道在哪些业务场景下才会被调用,但是不知道什么时候被调用.调用的频率.接口性能,当出现问题的时候也不容易重现请求:为了追踪这些内容就需要把每次接口的调用信息给完整的记录下来 ...
- 九度OJ 1201:二叉排序树 (二叉树)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4894 解决:2062 题目描述: 输入一系列整数,建立二叉排序数,并进行前序,中序,后序遍历. 输入: 输入第一行包括一个整数n(1< ...
- iOS设备获取总结
1.获取iOS设备的各种信息 // 这个方法后面会列出来 NSString *deviceName = [self getDeviceName]; NSLog(@"设备型号-->%@& ...
- DNN 数据的表示
- Python: generator, yield, yield from 详解
1.Generator Expressions 生成器表达式是用小括号表示的简单生成器标记法: generator_expression ::= "(" expression co ...