Codeforces Beta Round #1 C. Ancient Berland Circus (计算几何)
来源:互联网 发布:javlibrary新域名17 编辑:程序博客网 时间:2024/05/29 14:51
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.
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 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.
0.000000 0.0000001.000000 1.0000000.000000 1.000000
1.00000000
AC代码:
#pragma comment(linker, "/STACK:102400000,102400000")//#include<bits/stdc++.h>#include <stdio.h>#include <string.h>#include <algorithm>#include <iostream>#include <cstring>#include <vector>#include <map>#include <cmath>#include <queue>#include <set>#include <bitset>#include <iomanip>#include <list>#include <stack>#include <utility> using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int,int> pii;typedef vector<int> vi;const double eps = 1e-4; const int INF = 1e9+7; const ll inf =(1LL<<62) ;const int MOD = 1e9 + 7; const ll mod = (1LL<<32);const int N =1e6+6; const int M=100010;const int maxn=55555;#define mst(a) memset(a, 0, sizeof(a))#define M_P(x,y) make_pair(x,y)#define pi acos(-1.0)#define in freopen("in.txt","r",stdin) #define rep(i,j,k) for (int i = j; i <= k; i++) #define per(i,j,k) for (int i = j; i >= k; i--) #define lson l , mid , rt << 1 #define rson mid + 1 , r , rt << 1 | 1 const int lowbit(int x) { return x&-x; }//const int lowbit(int x) { return ((x)&((x)^((x)-1))); } int read(){ int v = 0, f = 1;char c =getchar();while( c < 48 || 57 < c ){if(c=='-') f = -1;c = getchar();}while(48 <= c && c <= 57) v = v*10+c-48, c = getchar();return v*f;}struct Point { double x,y; }; double dist(Point p1,Point p2) { return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)); } double Angle(double a,double b,double c) { return acos((a*a+b*b-c*c)/(2*b*a)); } double gcd(double a,double b) { if(b+eps>0&&b-eps<0)//注意eps的范围 return a; if(a+eps>0&&a-eps<0) return b; return gcd(b,fmod(a,b)); }int main() { Point p1,p2,p3; while(~scanf("%lf%lf%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y)) { double a,b,c,p,s,r; double angle1,angle2,angle3,angle; a=dist(p1,p2); b=dist(p1,p3); c=dist(p2,p3); //海伦公式 p=(a+b+c)/2; s=sqrt(p*(p-a)*(p-b)*(p-c)); r=a*b*c/(4*s); //外接圆半径 angle1=Angle(r,r,a); angle2=Angle(r,r,b); angle3=2*pi-angle1-angle2; angle=gcd(angle1,gcd(angle2,angle3)); //求得三个圆心角∠1、∠2和∠3的最大公约数angle double ans; //求正多边形的面积 //正多边形一共有2*pi/angle个小三角形 ///每个小三角形的面积为r^2*sin(angle)/2 ans=0.5*r*r*sin(angle)*(2*pi/angle); printf("%.6lf\n",ans); } return 0; }
- Codeforces Beta Round #1 C. Ancient Berland Circus (计算几何)
- codeforces Round #1 C题 Ancient Berland Circus (计算几何)
- Codeforces Beta Round #1 C. Ancient Berland Circus
- Codeforces Beta Round #1 C. Ancient Berland Circus
- Codeforces Beta Round #1 C Ancient Berland Circus
- Codeforces Beta Round #1 C. Ancient Berland Circus
- Codeforces Beta Round #1 C. Ancient Berland Circus
- Codeforces Beta Round #1 C. Ancient Berland Circus
- Codeforces 1C Ancient Berland Circus 计算几何
- Codeforces Round #1C Ancient Berland Circus
- Codeforces 1C. Ancient Berland Circus(计算几何:正多边形性质+高精度)
- Codeforces 1C Ancient Berland Circus
- CodeForces #1 C. Ancient Berland Circus
- codeforces 1C Ancient Berland Circus
- CodeForces-1C-Ancient Berland Circus
- CodeForces 1C Ancient Berland Circus
- CodeForces 1C - Ancient Berland Circus
- Codeforces #1 C. Ancient Berland Circus
- IT--linux-时间-date
- Linux基础知识学习:linux用命令重启
- 如何从MySQL官方Yum仓库安装MySQL5.6
- Android 资源杂谈
- Apache 2.4.x 的虚拟目录配置
- Codeforces Beta Round #1 C. Ancient Berland Circus (计算几何)
- 简单代码_循环_20160910
- 编码规范 by @mdo
- powershell中压缩与解压缩zip文件的问题
- 百度的地图开发API
- 工作一本通
- sql merge的用法
- Codeforces Round #364 (Div. 1) B. Connecting Universities(图论)
- 将已有项目提交到github/从github上pull到本地