HDU 6055 17多校 Regular polygon(计算几何)
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
using namespace std; bool vis[][];
//把所有值都加100 struct node
{
int x,y;
}point[]; bool cmp(node a,node b)
{
return a.x<b.x;
} bool judge(node c)
{
if(c.x>=&&c.x<=&&c.y>=&&c.y<=)
if(vis[c.x][c.y])
return true;
return false;
} int main()
{
int n,cnt;
while(~scanf("%d",&n))
{
memset(vis,false,sizeof(vis));
for(int i=;i<n;i++)
{
scanf("%d%d",&point[i].x,&point[i].y);
point[i].x+=;
point[i].y+=;
vis[point[i].x][point[i].y]=true;
}
sort(point,point+n,cmp);
cnt=;
node a,b,c,d;
int disx,disy;
for(int i=;i<n;i++)
{
for(int j=i+;j<n;j++)
{
a=point[i];
b=point[j];
disx=abs(a.y-b.y);
disy=abs(a.x-b.x);
if(b.y<=a.y)
{
//右上
c.x=b.x+disx;
c.y=b.y+disy;
d.x=a.x+disx;
d.y=a.y+disy;
if(judge(c)&&judge(d))
cnt++;
//左下
c.x=b.x-disx;
c.y=b.y-disy;
d.x=a.x-disx;
d.y=a.y-disy;
if(judge(c)&&judge(d))
cnt++;
}
else
{
//右下
c.x=b.x+disx;
c.y=b.y-disy;
d.x=a.x+disx;
d.y=a.y-disy;
if(judge(c)&&judge(d))
cnt++;
//左上
c.x=b.x-disx;
c.y=b.y+disy;
d.x=a.x-disx;
d.y=a.y+disy;
if(judge(c)&&judge(d))
cnt++;
}
}
}
printf("%d\n",cnt/);
}
return ;
}
HDU 6055 17多校 Regular polygon(计算几何)的更多相关文章
- HDU6055 Regular polygon(计算几何)
Description On a two-dimensional plane, give you n integer points. Your task is to figure out how ma ...
- hdu 4033 Regular Polygon 计算几何 二分+余弦定理
题目链接 给一个n个顶点的正多边形, 给出多边形内部一个点到n个顶点的距离, 让你求出这个多边形的边长. 二分边长, 然后用余弦定理求出给出的相邻的两个边之间的夹角, 看所有的加起来是不是2Pi. # ...
- HDU 6140 17多校8 Hybrid Crystals(思维题)
题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...
- HDU 6143 17多校8 Killer Names(组合数学)
题目传送:Killer Names Problem Description > Galen Marek, codenamed Starkiller, was a male Human appre ...
- HDU 6045 17多校2 Is Derek lying?
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6045 Time Limit: 3000/1000 MS (Java/Others) Memory ...
- HDU 6124 17多校7 Euler theorem(简单思维题)
Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...
- HDU 3130 17多校7 Kolakoski(思维简单)
Problem Description This is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1……. This seq ...
- HDU 6038 17多校1 Function(找循环节/环)
Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1. D ...
- HDU 6034 17多校1 Balala Power!(思维 排序)
Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. He want ...
随机推荐
- Mac OS下安装和配置MongoDB
安装和配置教程: 参考地址:https://blog.csdn.net/yibowanbo/article/details/80233030 可视化管理工具: 地址:https://blog.csdn ...
- miniui 使用心得
MiniUI demo实例使用心得:1.渲染速度很快2快速维护数据 3多种编辑方式 如 弹窗 直接下方显示form 下方显示tab 等4.树形 编辑 联动 5验证表单6文本框内 选择框 保存的多个选项 ...
- c# 线程的生命周期
对于线程而言有两种类型:前台线程,后台线程.前台与后台线程性质相同,但终止条件不同. 后台线程:在运行过程中如果宿主进程结束,线程将直接终止执行:在强制终止时,线程即终止执行不论线程代码是否执行完毕. ...
- UI基础二:下拉,F4,OP等
常用的搜索帮助有SE11的SH,域,值列表,组件等...下面介绍一下经常用的: 一:下拉 dropdown是最经常用的,也是最简单的一种. 不管是查询条件,还是结果清单,还是明细界面,下拉都是一样的 ...
- Maven管理jar包依赖常出现的不能实例化类的问题
you'ji 在maven管理jar包依赖时,存在一种常见的问题. pom.xml文件配置没问题,通过eclipse里中的maven dependencies查看,也确实有这个jar 包,或者这个类. ...
- git commit -am "remark" 提交
一.前言 假如你昨晚把本地文件a.html提交到远程库,今早发现还有补充的内容,于是添加了新的内容到a.html,并且还在本地还多添加了“几个文件”,那么怎么使用git来把这些文件一并提交到远程库呢? ...
- Python迭代和列表生成器
使用for循环遍历list和tuple,这种遍历成为迭代 在如C语言中都是通过下标拿到值,for...in这种方式其实是相同的. 在函数的一节,这样说--->‘求和函数sum(),sum(ite ...
- nginx是什么,如何使用
一:nginx是什么? 二:nginx作为网关,需要具备什么?(nginx可以作为web服务器,但更多的时候,我们把它作为网关,因为它具备网关必备的功能:) 反向代理(反向代理就是服务器找来一个机器代 ...
- zzw原创_根据某一文件复制出大量固定位数后缀名的递增的文件
1.trre.sh :根据某一文件复制出大量固定位数后后缀递增的文件. 如将 SPINFO_190516_20170109.001 复制成SPINFO_190516_20170109.002 ...
- thinkphp 3.2 加载第三方库 第三方命名空间库
tp 自动加载的介绍: http://document.thinkphp.cn/manual_3_2.html#autoload 第三方库不规范库 不适用命名空间的库 可以使用import函数导入,其 ...