POJ 1200 Crazy Search(RK)
摘要:题意给定一个由NC个字母组成的字符串,求长度为N的不同子串的个数思路:由于只有NC个字母,可以将字母编号,0 ~ NC - 1,转换成数字,就可以将字符串表示成NC进制的数字,这样所有字串代表的数字都是唯一的,转换成10进制的数也是唯一的!就像10的二进制表示只有1010例如3 4daababacd = 3a = 0b = 1c = 2daa = 3 * 4 ^ 2 + 0 * 4 ^ 1 + 0 * 4 ^ 0 = 48//vs1.0#include <stdio.h>#include <stdlib.h>#include <string.h>#defin
阅读全文
posted @
2012-07-24 03:14
Try86
阅读(286)
推荐(0)
hdu 1496(hash)
摘要:/** hash+数学,很好的题 * 对整数求hash,采用除余法,及线性探测解决冲突 * 注意:devc++中不能定义全局变量count,它和库函数中的函数名同名了 */#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 175447;int counts[M];int result[M];int temp[101];int hashInt(int s) { int k = s % M; if (k < 0) k += M; w
阅读全文
posted @
2012-04-09 21:05
Try86
阅读(248)
推荐(0)
hdu 1425(hash)
摘要:/** hash*/#include <cstdio>#include <climits>#include <cstring>#include <iostream>using namespace std;const int M = 1000001;bool hash[M];void init() { for (int i=0; i<M; ++i) hash[i] = false; return ; }int main() { int n, m, maxm; while (scanf("%d%d", &n, &am
阅读全文
posted @
2012-04-09 19:54
Try86
阅读(220)
推荐(0)
hdu 1800(hash)
摘要:/** 分析:题意要求找字符串个数最多的一个* 方法:很多,hash就是其中一种 * 注意两点:1.去掉前导0; 2.每组测试数据后,要释放内存 * 第一点解析:例如数据01,001,0001, 00001不去前导0的话,hash以后映射到不同的表位置 *//* Author: Try86 Date: 09/04/12 18:01*/#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 5471; //hash表大小struct node
阅读全文
posted @
2012-04-09 18:37
Try86
阅读(560)
推荐(0)
hdu 1075(hash)
摘要://字符串hash练手题,采用拉链式解决冲突 #include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 43853;//hash表大小 struct node {//节点 char str1[11]; char str2[11]; node *next; };struct hashTable {//hash表 node *link;}hash[M];char text[3005];char str1[11], str2[11], ch[11]
阅读全文
posted @
2012-04-09 17:49
Try86
阅读(165)
推荐(0)
hdu 1004(hash)
摘要://hash#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int M = 1361;struct node {//节点 char str[16]; int count; node *next;}s[M];int maxs;char ans[16];void init() {//初始化 for (int i=0; i<M; ++i) { s[i].next = NULL; s[i].count = 0; }}unsigned ...
阅读全文
posted @
2012-04-03 21:23
Try86
阅读(205)
推荐(0)