题意:

给你正n边形上的三个点,问n最少为多少

思路:

三个点在多边形上,所以三个点的外接圆就是这个正多边形的外接圆,余弦定理求出每个角的弧度值,即该角所对边的圆周角,该边对应的圆心角为圆心角的二倍。同时这个圆心角应为正多边形的每条边对应圆心角的整数倍,即2*pi/i的整数倍,遍历for i 1 to 1000 ,判断A*i/pi是否均为整数即可

坑点:

注意判断double是否为整数:return a-(int)(a+eps);

代码:

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<vector>
#include<map>
#include<functional> #define fst first
#define sc second
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,root<<1
#define rson mid+1,r,root<<1|1
#define lc root<<1
#define rc root<<1|1
#define lowbit(x) ((x)&(-x)) using namespace std; typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PLL; const db eps = 1e-;
const int mod = 1e9+;
const int maxn = 5e6+;
const int maxm = 2e6+;
const int inf = 0x3f3f3f3f;
const db pi = acos(-1.0); struct point{
double x, y;
point(double x = , double y = ):x(x), y(y){}
};
double length(point a, point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
bool ok(double a){
return a > &&fabs(a-(int)(a+eps)) < eps;
}
int main(){
point a, b, c;
while(scanf("%lf %lf", &a.x, &a.y) != ){
scanf("%lf %lf %lf %lf", &b.x, &b.y, &c.x, &c.y);
double ab = length(a, b);
double ac = length(a, c);
double bc = length(b, c);
double A = acos((ab*ab+ac*ac-bc*bc)/(2.0*ab*ac));
double B = acos((ab*ab+bc*bc-ac*ac)/(2.0*ab*bc));
double C = acos((ac*ac+bc*bc-ab*ab)/(2.0*ac*bc));
int flg = ;
for(int i = ; i <= ; i++){
if(ok(A*i/pi) && ok(B*i/pi) && ok(C*i/pi)){
flg = i;
break;
}
}
printf("%d\n", flg); }
return ;
}

HDU4195 Regular Convex Polygon (正多边形、外接圆)的更多相关文章

  1. HDU 4195 Regular Convex Polygon

    思路:三角形的圆心角可以整除(2*pi)/n #include<cstdio> #include<cstring> #include<iostream> #incl ...

  2. [LeetCode] Convex Polygon 凸多边形

    Given a list of points that form a polygon when joined sequentially, find if this polygon is convex ...

  3. Leetcode: Convex Polygon

    Given a list of points that form a polygon when joined sequentially, find if this polygon is convex ...

  4. HOJ 13101 The Triangle Division of the Convex Polygon(数论求卡特兰数(模不为素数))

    The Triangle Division of the Convex Polygon 题意:求 n 凸多边形可以有多少种方法分解成不相交的三角形,最后值模 m. 思路:卡特兰数的例子,只是模 m 让 ...

  5. ACM训练联盟周赛 G. Teemo's convex polygon

    65536K   Teemo is very interested in convex polygon. There is a convex n-sides polygon, and Teemo co ...

  6. 【LeetCode】469. Convex Polygon 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 计算向量夹角 日期 题目地址:https://leet ...

  7. Converting a Polygon ZM shape file to a regular Shape Polygon

    from:http://blog.csdn.net/qb371/article/details/8102109 Locate the following tool - ArcToolbox > ...

  8. HUNAN 11562 The Triangle Division of the Convex Polygon(大卡特兰数)

    http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11562&courseid=0 求n边形分解成三角形的 ...

  9. HNU 13101 The Triangle Division of the Convex Polygon 组合数的因式分解求法

    题意: 求第n-2个Catalan数 模上 m. 思路: Catalan数公式: Catalan[n] = C(n, 2n)/(n+1) = (2n)!/[(n+1)!n!] 因为m是在输入中给的,所 ...

随机推荐

  1. Java面向对象之异常【一】

    目录 Java面向对象之异常[一] 异常的继承体系 Error Exception 异常是否受检 unchecked exceptions(不受检异常) checked exceptions(受检异常 ...

  2. 快速幂模板Super

    //求x^nint ans=1;while(n){ if(n&1) ans=ans*x; x*=x; n>>=1;} 快速幂就是快速算底数的n次幂.其时间复杂度为 O(logN), ...

  3. python 生成器 yield语句

    生成器就是一个返回迭代器(iterator)的函数. 包含了 yield 的函数,就是一个生成器. 生成器每使用yield语句产生一个值,函数就会被冻结(暂停执行),被唤醒后(即再次调用)接着上次执行 ...

  4. dp - 递推

    C. Multiplicity time limit per test 3 seconds memory limit per test 256 megabytes input standard inp ...

  5. Logback源码分析

    在日常开发中经常通过打印日志记录程序执行的步骤或者排查问题,如下代码类似很多,但是,它是如何执行的呢? package chapters; import org.slf4j.Logger; impor ...

  6. Render函数详解

    一.虚拟dom DOM是文档对象模型(Document Object Model)的简写,在浏览器中通过js来操作DOM的操作性能很差,于是虚拟Dom应运而生.虚拟Dom就是在js中模拟DOM对象树来 ...

  7. xLua下使用lua-protobuf

    本文发表于程序员刘宇的博客,转载请注明来源:https://www.cnblogs.com/xiaohutu/p/12168781.html protobuf作为一种通用套接字格式,各种插件里,最本质 ...

  8. 在winform中使用cefsharp.winform嵌入浏览器(含视频教程)

    免费视频教程和源码: https://www.bilibili.com/video/av84573813/ 1. 开始使用CefSharp在Winform中嵌入网页 2. 解决重复打开Cefsharp ...

  9. 「 从0到1学习微服务SpringCloud 」12 Zuul的综合使用

    上次讲了Zuul的基本使用,这篇讲的是综合使用,比如过滤器,限流,鉴权等应用 这里继续使用api-getway这个项目 过滤器 实现token验证(前置过滤器) 1.新建一个类,继承ZuulFilte ...

  10. shh登入不能自动执行.bashrc

    在linux 上新安装的anconda来管理软件,把环境变量放在home目录的.bashrc.结果每次开终端,不能直接使用conda.需要手动加环境变量. 用户登入后计算机执行了哪些文件 用户登录时b ...