CodeForces 1C(计算几何)
来源:互联网 发布:万代告淘宝 编辑:程序博客网 时间:2024/05/29 08:29
问题描述:
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.
Example
0.000000 0.0000001.000000 1.0000000.000000 1.000000
1.00000000
题目题意:题目给我们一个正多边形的三个点,让我们求出这个多边形的可能最小面积。
题目分析:我们可以先利用这个三个点来求出外接圆的半径
R=a*b*c/4*s;
然后我们求出这个三角形三个内角,那么它对应的圆心角就是它角度的俩倍,也就是得到了三段弧长对应的角度,我们求这个三个角度的最大公约角D。
2*PI/D就是小三角形的个数,乘以每个三角形的面积就是多边形的面积。
题目题意:
#include<iostream>#include<cmath>#include<cstring>#include<cstdio>using namespace std;const double PI=acos(-1.0);const double eps=1e-2;//精度高了还不行struct note{ double x,y;}a,b,c;double get_dis(note a,note b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}double fgcd(double a,double b){ if (fabs(b)<eps) return a; return fgcd(b,fmod(a,b));}int main(){ while (scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)!=EOF) { double A,B,C,D,S,R,ac,bc,ab; ac=get_dis(a,c); ab=get_dis(a,b); bc=get_dis(b,c); A=acos((ac*ac+ab*ab-bc*bc)/(2*ac*ab)); B=acos((bc*bc+ab*ab-ac*ac)/(2*bc*ab)); C=acos((ac*ac+bc*bc-ab*ab)/(2*ac*bc)); R=bc/(2*sin(A)); A*=2,B*=2,C*=2; D=fgcd(fgcd(A,B),fgcd(A,C)); printf("%.8f\n",R*R*sin(D)/2.0*((2*PI)/D)); } return 0;}
- CodeForces 1C(计算几何)
- codeforces 1C 计算几何
- Codeforces 1C Ancient Berland Circus 计算几何
- CodeForces 281c Rectangle Puzzle 计算几何
- CodeForces 618 C. Constellation(计算几何)
- Codeforces 703C 思维or计算几何
- Codeforces 1C. Ancient Berland Circus(计算几何:正多边形性质+高精度)
- codeforces Round #1 C题 Ancient Berland Circus (计算几何)
- Codeforces Beta Round #1 C. Ancient Berland Circus (计算几何)
- CodeForces 614C Peter and Snow Blower【计算几何】
- CodeForces 274C|275E|The Last Hole!|计算几何
- Codeforces Round #365 (Div. 2) C 计算几何
- Codeforces 703C Chris and Road(计算几何)
- ☆ Codeforces 724C Ray Tracing 扩展欧几里得 + 计算几何
- 【CodeForces】257C - View Angle(计算几何)
- Codeforces 560C Gerald's Hexagon【计算几何】
- CodeForces 196 C.Paint Tree(计算几何+递归)
- Codeforces 851C . Five Dimensional Points 计算几何,结论
- 10016
- linux 系统安全命令
- MVC模式
- 非空格式验证框架--Validation的使用
- html中文乱码怎么解决?
- CodeForces 1C(计算几何)
- 疯狂JAVA讲义-接口和抽象类比较
- usaco Palindromic Squares
- python环境安装tensorflow
- 使用@Aspect做android AOP开发遇到的Android aspect No such property: project for class:
- GCD实用篇(会持续更新)
- KNN学习及实现
- 画风茜茜
- iOS开发无法导出p12证书的问题解决办法