HDU 6055 Regular polygon (暴力)
题意,二维平面上给N个整数点,问能构成多少个不同的正多边形。
析:容易得知只有正四边形可以使得所有的顶点为整数点。所以只要枚举两个点,然后去查找另外两个点就好。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#include <list>
#define debug() puts("++++");
#define gcd(a, b) __gcd(a, b)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 500 + 10;
const LL mod = 1e9 + 7;
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool is_in(int r, int c){
return r > 0 && r <= n && c > 0 && c <= m;
} map<P, int> mp;
P p[maxn]; P solve(const P &p1, const P &p2){
int detx = p2.first - p1.first;
int dety = p2.second - p1.second;
return P(p1.first-dety, p1.second+detx);
} int main(){
while(scanf("%d", &n) == 1){
mp.clear();
for(int i = 0; i < n; ++i){
scanf("%d %d", &p[i].first, &p[i].second);
mp[p[i]] = true;
} int ans = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < n; ++j){
if(i == j) continue;
P p1 = solve(p[i], p[j]);
if(!mp.count(p1)) continue;
P p2 = solve(p1, p[i]);
if(!mp.count(p2)) continue;
++ans;
}
}
printf("%d\n", ans/4);
}
return 0;
}
HDU 6055 Regular polygon (暴力)的更多相关文章
- HDU 6055 - Regular polygon | 2017 Multi-University Training Contest 2
/* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= ...
- HDU 6055 Regular polygon
Regular polygon Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 6055 Regular polygon —— 2017 Multi-University Training 2
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 ...
- 2017 Multi-University Training Contest - Team 2 &hdu 6055 Regular polygon
Regular polygon Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 【2017多校训练2+计算几何+板】HDU 6055 Regular polygon
http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为 ...
- hdu 6055 : Regular polygon (2017 多校第二场 1011) 【计算几何】
题目链接 有个结论: 平面坐标系上,坐标为整数的情况下,n个点组成正n边形时,只可能组成正方形. 然后根据这个结论来做. 我是先把所有点按照 x为第一关键字,y为第二关键字 排序,然后枚举向量 (p[ ...
- hdu 4033 Regular Polygon 计算几何 二分+余弦定理
题目链接 给一个n个顶点的正多边形, 给出多边形内部一个点到n个顶点的距离, 让你求出这个多边形的边长. 二分边长, 然后用余弦定理求出给出的相邻的两个边之间的夹角, 看所有的加起来是不是2Pi. # ...
- HDU 6055 17多校 Regular polygon(计算几何)
Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure ou ...
随机推荐
- 重装系统, i tell you
博客网站: https://blog.csdn.net/ca1m0921/article/details/79313050 装机例子1: http://www.xitongcheng.com/jiao ...
- 容器中跨主机的网络方案-Weave
容器中的网络是建立docker集群的重要内容. 本文将介绍如何用Weave实现容器的多节点互通. Weave是一个开源的项目,其网站为: https://www.weave.works/ 其工作原理相 ...
- erlang的dict和maps模块
erlang在r17以后增加了map这个数据结构,在之前,类似map的需求用dict模块来实现,这里直接贴一下相关的操作 dict D = dict:new(). D1 = dict:store(k1 ...
- redis list结构
一个功能肯定有其应用场景: PUSH和POP操作,其实是队列的基本操作.Redis的list就是一个极其强大的队列系统.我们在哪些地方会用到队列呢?下面,我们说两个例子: a,评论系统 逛过微博的筒子 ...
- S3C2440 SPI驱动框架
S3C2440 SPI驱动代码详细解读: https://www.linuxidc.com/Linux/2012-08/68402p4.htm 一.platform device and board_ ...
- (转)Oracle 临时表用法
本文转载自:http://www.iteye.com/topic/371390 ORACLE的临时表在应用系统中有很大的作用,它可以让用户只能够操作各自的数据中而互不干扰,不用担心会破坏或影响其他SE ...
- npm国内镜像介绍
这个也是网上搜的,亲自试过,非常好用! 镜像使用方法(三种办法任意一种都能解决问题,建议使用第三种,将配置写死,下次用的时候配置还在): 1.通过config命令 npm config set reg ...
- jenkins使用HTML Publisher Plugin插件 拉取报告样式缺失问题解决
---------------------------------------------------------临时解决方案----亲测ok 要解决该问题,方式也比较简单,就是修改Content S ...
- 安装appium需要注意的事项
参考 虫师 的博客园 :http://www.cnblogs.com/fnng/p/4560298.html 1.其中第二篇中,打开命令行用的不是windows中的cmd打开的界面,而是用node. ...
- Java-Maven-Runoob:Maven 快照(SNAPSHOT)
ylbtech-Java-Maven-Runoob:Maven 快照(SNAPSHOT) 1.返回顶部 1. Maven 快照(SNAPSHOT) 一个大型的软件应用通常包含多个模块,并且通常的场景是 ...