HDU 4195 Regular Convex Polygon
思路:三角形的圆心角可以整除(2*pi)/n
#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
#define clc(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
const int N=;
#define LL long long
const double eps = 1e-;
const double pi = acos(-);
// inline int r(){
// int x=0,f=1;char ch=getchar();
// while(ch>'9'||ch<'0'){if(ch=='-') f=-1;ch=getchar();}
// while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
// return x*f;
// }
struct Point{
double x,y;
Point(double a=,double b=):x(a),y(b){}
}; double angle(Point a,Point b,Point c){
b.x-=a.x,b.y-=a.y;
c.x-=a.x,c.y-=a.y;
return acos((b.x*c.x+b.y*c.y)/(hypot(b.x,b.y)*hypot(c.x,c.y)));
} bool dcmp(double f,int n){
return fabs(f * n - round(f * n)) < eps;
} int main(){
while(){
Point p[];
for(int i=;i<;i++)
if(scanf("%lf%lf",&p[i].x,&p[i].y)!=) return ;
double a=angle(p[],p[],p[])/pi;
double b=angle(p[],p[],p[])/pi;
for(int i=;i<=;i++){
if(dcmp(a,i)&&dcmp(b,i)){
printf("%d\n",i);
break;
}
}
}
return ;
}
HDU 4195 Regular Convex Polygon的更多相关文章
- HDU4195 Regular Convex Polygon (正多边形、外接圆)
题意: 给你正n边形上的三个点,问n最少为多少 思路: 三个点在多边形上,所以三个点的外接圆就是这个正多边形的外接圆,余弦定理求出每个角的弧度值,即该角所对边的圆周角,该边对应的圆心角为圆心角的二倍. ...
- HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2
/* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...
- [LeetCode] Convex Polygon 凸多边形
Given a list of points that form a polygon when joined sequentially, find if this polygon is convex ...
- Leetcode: Convex Polygon
Given a list of points that form a polygon when joined sequentially, find if this polygon is convex ...
- HOJ 13101 The Triangle Division of the Convex Polygon(数论求卡特兰数(模不为素数))
The Triangle Division of the Convex Polygon 题意:求 n 凸多边形可以有多少种方法分解成不相交的三角形,最后值模 m. 思路:卡特兰数的例子,只是模 m 让 ...
- ACM训练联盟周赛 G. Teemo's convex polygon
65536K Teemo is very interested in convex polygon. There is a convex n-sides polygon, and Teemo co ...
- 【LeetCode】469. Convex Polygon 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 计算向量夹角 日期 题目地址:https://leet ...
- HDU 6055 Regular polygon
Regular polygon Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 2017ACM暑期多校联合训练 - Team 2 1011 HDU 6055 Regular polygon (数学规律)
题目链接 **Problem Description On a two-dimensional plane, give you n integer points. Your task is to fi ...
随机推荐
- testlink的下载地址
http://sourceforge.jp/projects/sfnet_testlink/downloads/TestLink%201.9/TestLink%201.9.12/testlink-1. ...
- 数位DP入门之hdu 3555 Bomb
hdu 3555 Bomb 题意: 在1~N(1<=N<=2^63-1)范围内找出含有 ‘49’的数的个数: 与hdu 2089 不要62的区别:2089是找不不含 '4'和 '62'的区 ...
- 自定义MVC路由配置
首先我用MVC4新增一个订单查看的功能 1.创建控制器OrderController namespace MvcApplication3.Controllers { public class Orde ...
- linux下i2c驱动笔记 转
1. 几个基本概念 1.1. 设备模型 由 总线(bus_type) + 设备(device) + 驱动(device_driver) 组成,在该模型下,所有的设备通过总线连接起来,即使有些设备没有连 ...
- python 文件查找 glob
glob模块是最简单的模块之一,内容非常少.用它可以查找符合特定规则的文件路径名.跟使用windows下的文件搜索差不多.查找文件只用到三个匹配符:"*", "?&quo ...
- 基于android混合开发的JsBridge技术学习
1.无JsBridge. js如果要调用java(native.也说原生)方法:则java必须实现js接口供挂载在window对象上供js来执行. 这里简单的可以只调用,调用后java端什么也不做.复 ...
- JAVA自学之-----FileInputStream类
1, FileInputStream类函数创建: package coreJava; import java.io.FileInputStream; import java.io.IOExceptio ...
- GCC 警告提示的用法
转自GCC 警告提示的用法 本节主要讲解GCC的警告提示功能.GCC包含完整的出错检查和警告提示功能,它们可以帮助Linux程序员写出更加专业和优美的代码.我们千万不能小瞧这些警告信息,在很多情况下, ...
- Es索引优化
https://www.elastic.co/guide/en/elasticsearch/guide/current/hardware.html https://www.elastic.co/gui ...
- POJ2302
简单题. #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm ...