Ancient Berland Circus CodeForces - 1C
题意:给定一个正多边形的三个顶点,求这个正多边形的最小面积。
思路:首先,边数越小面积越小,所以只要确定出包含这三个顶点的边数最小的正多边形即可。这个三角形和正多边形外接同一个圆。所以先求出外接圆的半径,再求出三个圆心角,易得这个多边形的边所对应的圆心角可被这三个圆心角整除,所以三个圆心角的gcd就是多边形边所对的圆心角,然后2π除一下就得到是几边形,之后就可计算面积了
海伦公式: p=(a+b+c)/2,S=√p(p-a)(p-b)(p-c)(a,b,c为三角形的三边,S为三角形面积)
求外接圆半径r=a*b*c/4S
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<stack> #include<cstdlib> #include<queue> #include<set> #include<string.h> #include<vector> #include<deque> #include<map> using namespace std; #define INF 0x3f3f3f3f #define eps 1e-4 #define bug printf("*********\n") #define debug(x) cout<<#x"=["<<x<<"]" <<endl typedef long long LL; typedef long long ll; const int MAXN = 1e6 + 5; const int mod = 998244353;struct node{double x,y; }; double len(node a,node b) {double tmp = sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));return tmp; } double gcd(double x,double y) {while(fabs(x) > eps && fabs(y) > eps) {if(x > y)x -= floor(x / y) * y;elsey -= floor(y / x) * x;}return x + y; } int main() {node a,b,c;cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y;double lena = len(a,b);double lenb = len(b,c);double lenc = len(a,c);double p = (lena + lenb + lenc) / 2.0;double S = sqrt(p * (p - lena) * (p - lenb) * (p - lenc));double R = lena * lenb * lenc / (4.0 * S);double A = acos((lenb * lenb + lenc * lenc - lena * lena) / (2 * lenb * lenc));double B = acos((lena * lena + lenc * lenc - lenb * lenb) / (2 * lena * lenc));double C = acos((lena * lena + lenb * lenb - lenc * lenc) / (2 * lena * lenb));double PI = acos(-1.0);double n = PI / gcd(gcd(A,B),C);double ans = n / 2 * R * R * sin(2 * PI / n);printf("%.10f\n",ans); }
转载于:https://www.cnblogs.com/smallhester/p/11361273.html
Ancient Berland Circus CodeForces - 1C相关推荐
- 数论六之计算几何——An Easy Problem,Ancient Berland Circus,Open-air shopping malls
可检验模板正确度 An Easy Problem?! Ancient Berland Circus Open-air shopping malls An Easy Problem?! problem ...
- 1.19 Ancient Berland Circus
古老的伯兰德马戏团 Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the pa ...
- 2022.01.19翻译Ancient Berland Circus
Ancient Berland Circus 题目(https://acs.jxnu.edu.cn/problem/CF1C)描述: Nowadays all circuses in Berland ...
- Ancient Berland Circus
描述: Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past thi ...
- Codeforces Beta Round #1 A,B,C
A. Theatre Square time limit per test:1 second memory limit per test:256 megabytes input:standard in ...
- codeforces beta round 1
codeforces beta round 1 A Theatre Square in the capital city of Berland has a rectangular shape with ...
- Educational Codeforces Round 88 (Rated for Div. 2)(AB)
Berland Poker CodeForces - 1359A 代码如下: #include<bits/stdc++.h> #define ll long long using name ...
- Educational Codeforces Round 120 (Rated for Div. 2)
题目列表 1.A. Construct a Rectangle-Educational Codeforces Round 120 (Rated for Div. 2) 2.B. Berland Mus ...
- 【CF37E】 Trial for Chief
题目 题意翻译 题意是给你一张N*M的图,每个点有黑色和白色,初始全为白色,每次可以把一个相同颜色的连续区域染色,求最少的染色次数: 题目描述 Having unraveled the Berland ...
最新文章
- js base64 编码解码
- mysql 5.7 Stage Tracking DDL进度跟踪
- 软工Chapter Seven
- tensorflow的tf.transpose()简单使用
- Java黑皮书课后题第3章:**3.22(几何:点是否在圆内)编写程序,提示用户输入一个点(x,y),然后检查这个点是否在以(0,0)为圆心、半径为10的圆内
- 计算机游戏50关,YELLOW游戏全50关攻略
- WPF中的鼠标事件详解
- ajax 输入不为空,ajax POST响应为空
- 想学会财务分析:先看懂三大表
- 设置linux的console为串口【转】
- 计算机组装与维护推荐教材,计算机组装与维护(全国高等专科教育计算机类规划教材)...
- MSE(Media Source Extensions)介绍
- LOJ10092半连通子图
- android设备调用usb外置摄像头方法及案例
- 大学生网页设计作业的20款优秀HTML5制作工具
- 使用C++实现FC红白机模拟器 概述
- 径向偏振光激发环偶极子
- navicat12No All Pattern Found!File Already Patched。
- linux系统缺少perl组建中的Data::Dumper模块
- UBUNTU环境下编译的openwrt