#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define MAXN 1111
using namespace std;
class Point{
public:
int x,y;
bool operator < (const Point &p) const{
if(x == p.x) return y < p.y;
return x < p.x;
}
bool operator == (const Point &p) const{
return x == p.x && y == p.y;
}
};
Point P[MAXN];
bool Binary_Search(const Point target,int len){
int l = ,r = len,mid;
while(l <= r){
mid = (l+r) >> ;
if(target == P[mid]) return true;
else if(target < P[mid]) r = mid-;
else l = mid+;
}
return false;
}
int main(){
int n,ans;
freopen("in.c","r",stdin);
while(~scanf("%d",&n) && n){
for(int i = ;i < n;i ++) scanf("%d%d",&P[i].x,&P[i].y);
sort(P,P+n);
ans = ;
for(int i = ;i < n;i ++){
for(int j = i+;j < n;j ++){
Point tmp1,tmp2;
tmp1.x = P[i].x+P[i].y-P[j].y,tmp1.y = P[i].y-P[i].x+P[j].x;
tmp2.x = P[j].x+P[i].y-P[j].y,tmp2.y = P[j].y-P[i].x+P[j].x;
if(Binary_Search(tmp1,n) && Binary_Search(tmp2,n)) ans++;
}
}
printf("%d\n",ans >> );
}
return ;
}

POJ -- 2002的更多相关文章

  1. POJ 2002 统计正方形 HASH

    题目链接:http://poj.org/problem?id=2002 题意:给定n个点,问有多少种方法可以组成正方形. 思路:我们可以根据两个点求出对应正方形[有2个一个在两点左边,一个在两点右边] ...

  2. POJ 2002 Squares 哈希

    题目链接: http://poj.org/problem?id=2002 #include <stdio.h> #include <string.h> ; struct Has ...

  3. POJ 2002 Squares 几何, 水题 难度: 0

    题目 http://poj.org/problem?id=2002 题意 已知平面内有1000个点,所有点的坐标量级小于20000,求这些点能组成多少个不同的正方形. 思路 如图,将坐标按照升序排列后 ...

  4. POJ 2002 Squares 数学 + 必须hash

    http://poj.org/problem?id=2002 只能说hash比二分快很多.随便一个hash函数都可以完爆二分. 判断是否存在正方形思路如下: 1.枚举任意两个点,作为正方形的一条边,那 ...

  5. POJ 2002 Squares 解题报告(哈希 开放寻址 & 链式)

    经典好题. 题意是要我们找出所有的正方形.1000点,只有枚举咯. 如图,如果我们知道了正方形A,B的坐标,便可以推测出C,D两点的坐标.反之,遍历所有点作为A,B点,看C,D点是否存在.存在的话正方 ...

  6. POJ 2002 Squares【值得摸索的一道二分+点旋转】

    id=2002">Squares 很好的一道二分,事实上本来我是没有思路的,看了基神的题解之后才似乎明确了点. 题意:给出最多有1000个点,问这些点能够组成多少个正方形 分析:先想想 ...

  7. 哈希 poj 2002

    n个点 求其中有几个正方形 n<1000 暴力4个点就不行了 大概2个点还可以 根基(x*x+y*y)%素数 hash 一下 告诉你2个点求 另外2个点 画个图推一下 重复要/2; #inclu ...

  8. POJ 2002 Squares

    二分.... Squares Time Limit: 3500MS Memory Limit: 65536K Total Submissions: 14530 Accepted: 5488 Descr ...

  9. Ultra-QuickSort (poj 2002)

    Description In this problem, you have to analyze a particular sorting algorithm. The algorithm proce ...

随机推荐

  1. iOS-开发记录-UIView属性

    UIView属性 1.alpha 设置视图的透明度.默认为1. // 完全透明 view.alpha = ; // 不透明 view.alpha = ; 2.clipsToBounds // 默认是N ...

  2. 当传递具有已修改行的 DataRow 集合时,更新要求有效的 UpdateCommand问题解决

    1.目前看主要因为两种,第一种是select语句没有包含主键列,select *  就可以解决.或 select 主键列 这里的主键是指的primary key而不是unique key 2.最重要的 ...

  3. 使用宏定义来减少JNI的繁琐

    本篇文章由:http://www.sollyu.com/use-macro-definitions-to-reduce-tedious-jni/ 说明 相信写过cocos2d-x的朋友,或者写过jni ...

  4. centOS 6 python MySQLdb 提示 no module

    http://www.cnblogs.com/czh-liyu/archive/2012/11/30/2796028.html(转) 用python连接本地数据库时,提示no module MySQL ...

  5. ubuntu logout 命令

    gnome-session-quit 点击打开链接http://askubuntu.com/questions/15795/how-can-you-log-out-via-the-terminal

  6. 一个关于hightcharts的x轴刻度问题

    最近做公司的一个报表系统,需要折线图,圆柱图形等来进行统计,经过最后考察,决定用当下较为流行的Highchart插件来进行实现,highchart用起来非常方便,只用对后台传过来的数据进行简单的处理后 ...

  7. ruby环境sass编译中文出现Syntax error: Invalid GBK character错误解决方法

    sass文件编译时候使用ruby环境,无论是界面化的koala工具还是命令行模式的都无法通过,真是令人烦恼. 容易出现中文注释时候无法编译通过,或者出现乱码,找了几天的解决方法终于解决了. 这个问题的 ...

  8. Linux - tar命令过滤某个目录

    tar -zcvf abc.20140325.tar.gz --exclude=./abc/kkk/--exclude=./abc/hhh/ ./abc/ 发现没有过滤成功,后来发现这种方法是不对的( ...

  9. Activity的窗口对象(Window)的创建过程分析

    与Activity组件所关联的窗口对象的实际类型为PhoneWindow,后者是从Window类继承下来的. Activity.Window和PhoneWindow三个类的关系如下 PhoneWind ...

  10. C++顺序容器类总结

    主要是vector,deque,list,forward_list,array,string 插入方法: 元素访问: 元素删除: 容器赋值: forward_list有很多特殊的方法 毕竟平时forw ...