
hash
vsooda
这个作者很懒,什么都没留下…
展开
-
HDU 1496 等式求解 简单hash
没有判断同号,超时了半天。 #include using namespace std; #define N 2000010 #define M 1000010 int res[N]; int res2[N]; int t[101]; int main() { for(int i = 0; i <= 100; i++) { t[i] = i * i; } int a, b, c,原创 2013-01-25 19:02:56 · 629 阅读 · 0 评论 -
HDU 1381 hash
主要思路:将出现的字符用nc进制的数来表示,保证其不会重复出现。。若有重复子字符串则这个数就相同,len-n+1 总的子字符串个数。。这个需要仔细观察。hash存储查找一遍重复的--最后就只剩下不重复的子字符串的个数了。 #include #include #define N 16000007 int hash[8000000],assi[27]; char str[N]; int a原创 2013-01-25 16:26:17 · 1359 阅读 · 1 评论 -
HDU 2546 01背包,可达性问题 hash思想
类似01背包。用hs[n]= 1表示是否可达。 可以证明如果饭卡的钱大于5的话,必然会点价格最高的菜。 所以问题转化为求m-5范围内点菜。越接近越好。这就是01背包。。 #include using namespace std; const int N = 1105; int hs[N]; int price[N]; int main() { int n, m; while(scanf原创 2013-01-28 15:32:33 · 1088 阅读 · 0 评论