
ACM之hash
文章平均质量分 66
noname40
这个作者很懒,什么都没留下…
展开
-
ELFhash函数
算法: 1.把字符串的每个字符依次相加,每次将加的结果向左移动4位。 2.如果加的结果大于28位,对结果向右移动24位与原值取异或 出处:http://www.bigwind.me/archives/260.html / ELF Hash Function unsigned int ELFHash(char *str) { unsigned int hash =转载 2012-02-10 20:20:30 · 553 阅读 · 0 评论 -
hdu 1425 简单的数的hash
题意:求出给出的数中从大到下的m个数。 思路:hash #include #define MAX 1000001 #define N 500000//根据数的范围来看,保证数组不越界 using namespace std; int main() { bool hash[MAX]; int n,m,h,num,t; while(scanf("%d%d",&n,&m)!=原创 2012-02-10 21:51:19 · 414 阅读 · 0 评论 -
hdu 1496 hash 方程解的情况
题意:根据题中所给的方程,输出a,b,c,d,输出满足方程的解的方案的个数 思路:hash x1,x2 和 x3,x4 如果两个状态存储的位置相同那么方案数加一,最后求出的方案乘以2^4,因为四个未知数是平方项,正负对其没有影响。 #include using namespace std; int hash[2000005]; int main() { int pin[105],i原创 2012-02-10 21:59:47 · 584 阅读 · 0 评论 -
hdu 1800 字符串的hash(BKDRHash 模版)大牛推荐的函数
题意:看LCY的课件,脱去题的马甲,意思就是求最有多少个重复的数字,数字要去掉前导零。 思路:hash #include #define maxn 249997 using namespace std; int hash[maxn],coun[maxn]; int ans; unsigned int BKDRHash(char*str) { unsigned int seed=13原创 2012-02-10 22:10:43 · 3328 阅读 · 4 评论 -
poj 2002 HASH判断正方形
题意:给出一些直角坐标系的点,求这些点可以组成多少个正方形。 思路:hash 正方形一条边的两个点的和,然后求另外两个点,如果可以找到构成这个正方形的点的话,个数加一 #include #include #define M 1031 using namespace std; struct point { int x,y; }; point P[1024]; int cmp(const vo原创 2012-02-12 09:09:32 · 651 阅读 · 0 评论