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 ...
随机推荐
- jquery解决file上传图片+图片预览
js解决file上传图片+图片预览 demo案例中代码为js原生控制,可以根据项目的需求修改为jquery操作 <!DOCTYPE html><html lang="en& ...
- PAT 1019 General Palindromic Number
1019 General Palindromic Number (20 分) A number that will be the same when it is written forwards ...
- Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc.xml] cannot be opene
Caused by: java.io.FileNotFoundException: class path resource [spring/springmvc. ...
- OSS 实例
步骤 1.初始化ossClient实例 2.判断bucket是否存在(doesBucketExist) 3.上传图片(putObject(bucket,key,file))(注意:key是图片所在的路 ...
- Oracle Log Block Size
Although the size of redo entries is measured in bytes, LGWR writes the redo to the log files on dis ...
- APK骨架分析
APK反编译的一般步骤是: 使用apktool将apk文件解压(后辍apk改为rar用winrar也可解压但这样不能解密res/value目录下的各文件),厉害的可以直接静态分析smali文件(ida ...
- ECMAscript5中的map
今天看到到这样一个问题: ["1", "2", "3"].map(parseInt) 执行结果是什么? 结果是[1,NAN,NAN],很出乎 ...
- learning ddr RTT
Rtt: Dynamic ODT.DDR3引入的新特性.在特定的应用环境下为了更好的在数据总线上改善信号完整性, 不需要特定的MRS命令即可以改变终结强度(或者称为终端匹配).在MR2中的A9和A10 ...
- Android 应用基础知识和应用组件
应用基础知识 安装到设备后,每个 Android 应用都运行在自己的安全沙箱内: Android 操作系统是一种多用户 Linux 系统,其中的每个应用都是一个不同的用户: 默认情况下,系统会为每个应 ...
- String常用方法
1. String StringBuffer StringBuilder的区别: 001.在执行速度方法 StringBuilder > StringBuffer > String 002 ...