Squares(哈希)】的更多相关文章

Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 14328   Accepted: 5393 Description A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its ce…
Description A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating about its centre by 90 degrees gives the same polygon. It is not the only polygon with the latte…
                                                       Squares 题意:二维坐标轴给出n个点求有多少个正方形. 要是平时做比赛的话毫无疑问会想到用二分去写这道题,但毕竟出现在hash专题里,所以自然用hash去攻克,但是完全没有思路,于是,,网上找了题解,让我感叹的是我们做hash的题怎么知道用哪种hash函数呢..这道题以坐标平方和再对hash数组大小取余,这样离散化感觉有点钻数据空子,但hash是有处理冲突的能力的,存在冲突怎么办呢…
题目链接: http://poj.org/problem?id=2002 #include <stdio.h> #include <string.h> ; struct Hash_table { int x, y; struct Hash_table *next; }*Hash[prime]; void Hash_insert(int x, int y) { int key = (x + y) % prime; if(Hash[key] == NULL) { Hash[key] =…
Squares Time Limit: 3500MS   Memory Limit: 65536K Total Submissions: 15137   Accepted: 5749 Description A square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that rotating abou…
During a discussion of problems at the Petrozavodsk Training Camp, Vova and Sasha argued about who of them could in 300 minutes find a pair of equal squares of the maximal size in a matrix of size N × M containing lowercase English letters. Squares c…
Description During a discussion of problems at the Petrozavodsk Training Camp, Vova and Sasha argued about who of them could in 300 minutes find a pair of equal squares of the maximal size in a matrix of size N × M containing lowercase English letter…
经典好题. 题意是要我们找出所有的正方形.1000点,只有枚举咯. 如图,如果我们知道了正方形A,B的坐标,便可以推测出C,D两点的坐标.反之,遍历所有点作为A,B点,看C,D点是否存在.存在的话正方形数+1. 假设A点坐标为(x1,y1),B点坐标为(x2,y2),则根据三角形全等,易知 C点坐标:( x1+(y2-y1),y1-(x2-x1) ) D点坐标:( x2+(y2-y1),y2-(x2-x1) ) 当然,如果我们遍历任意两个点,一个正方形将会被计数四次(四条边).我们可以只判断斜率…
题目大意:原题链接 给定平面上的N个点,求出这些点一共可以构成多少个正方形. 解题思路: 若正方形为ABCD,A坐标为(x1, y1),B坐标为(x2, y2),则很容易可以推出C和D的坐标.对于特定的A和B坐标,C和D可以在线段AB的上面或者下面,即有两种情况.           根据构造三角形全等可以得知(很简单,注意下细节,不要把坐标弄混就行) CD在AB上面x3=x2+(y1-y2),y3=y2+(x2-x1);    x4=x1+(y1-y2),y4=y1+(x2-x1); CD在A…
题目链接:http://poj.org/problem?id=2002 测试数据: 41 00 11 10 090 01 02 00 21 22 20 11 12 14-2 53 70 05 20 有两种解法,第一种用二分查找,第二种用到hash存储: 解法一: #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> usi…