poj 2002 Squares(hash)
来源:互联网 发布:网络创世纪uo 音乐 编辑:程序博客网 时间:2024/05/18 03:39
意义
给你n个点的坐标,问你可以围成多少个正方形。
思路
可以得出
temp.x = p[i].x + (p[i].y - p[j].y);
temp.y = p[i].y + (p[j].x - p[i].x);
和
temp.x = p[j].x + (p[i].y - p[j].y);
temp.y = p[j].y + (p[j].x - p[i].x);
然后就可以枚举两个点了,搞搞就好了。
const maxn=999987;var x,y,hash:array [1..maxn] of longint; ans,i,j,n:longint;procedure insertion(x,y:longint);var i:longint; k:int64;begin k:=x*50000+y; i:=abs(k) mod maxn; while (hash[i]<>-5201314) and (hash[i]<>k) do i:=i mod maxn+1; hash[i]:=k;end;function find(x,y:longint):boolean;var i:longint; k:int64;begin k:=x*50000+y; i:=abs(k) mod maxn; while (hash[i]<>-5201314) and (hash[i]<>k) do i:=i mod maxn+1; if hash[i]=k then exit(true) else exit(false);end;begin readln(n); while n<>0 do begin for i:=0 to maxn do hash[i]:=-5201314; ans:=0; for i:=1 to n do begin readln(x[i],y[i]); insertion(x[i],y[i]); end; for i:=1 to n do for j:=i+1 to n do if (find((y[i]-y[j])+x[i],((x[j]-x[i])+y[i]))) and (find((y[i]-y[j])+x[j],(x[j]-x[i])+y[j])) then inc(ans); writeln(ans div 2); readln(n); end;end.
0 0
- POJ 2002 Squares Hash
- POJ 2002 Squares -- Hash
- poj 2002 Squares,hash
- POJ 2002 Squares (Hash)
- poj 2002 Squares Hash
- POJ 2002 Squares hash
- poj 2002 Squares(hash)
- POJ 2002 - Squares(hash)
- POJ 2002 Squares(hash)
- POJ-2002-Squares(hash)
- poj 2002 Squares【HASH】POJ最快
- POJ 2002 Squares hash/计算几何
- poj 2002 Squares(枚举+点hash)
- Poj 2002 Squares (正方形个数 Hash)
- POJ 2002 Squares hash求正方形个数
- poj 2002 :Squares(hash 不解释)
- POJ 2002 Squares(hash+二分查找)
- POJ 2002 Squares(计算几何 找正方形 hash枚举)
- API 25 (Android 7.1.1 API) animation.Animator
- 对称密码之DES
- Dojo1.11官方教程文档翻译(4.7)Deferred入门
- HUD - 1575 - Tr A ( 矩阵快速幂,简单题目 )
- 关于进不去android查看DDMS里的数据库问题
- poj 2002 Squares(hash)
- 商业化外骨骼对比
- 正则表达式及其应用示例
- 如何在mac系统下搭建git服务器
- spring aop中的propagation的7种配置的意思
- 第15周 oj Problem L: 字符串替换(串)
- 斐波那契之兔子问题解释
- neo4j 下载地址 以及手册下载地址
- Leveldb 实现原理