![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
哈希
HonniLin
double fighting
展开
-
UVA 12012 - Detection of Extraterrestrial (KMP / 哈希)
E.T. Inc. employs Maryanna as alien signal researcher. To identify possible alien signals and background noise, she develops a method to evaluate the signals she has already received. The signal sent原创 2014-11-26 17:48:24 · 610 阅读 · 0 评论 -
POJ 2002 - Squares(hash)
题目:http://poj.org/problem?id=2002 题意: 给出n个点的坐标(x,y),求出能组成正方形的个数。 思路: 首先应该知道的是知道正方形一条边上的两个点 (x1,y1) (x2,y2): 另外两个点的坐标: 则: x3=x1+(y1-y2) y3= y1-(x1-x2) x4=x2+(y1-y2) y4= y2-(x1-x2) 或 x原创 2015-02-21 20:54:00 · 460 阅读 · 0 评论 -
POJ 1840 - Eqs(数学)
题目: http://poj.org/problem?id=1840 题意: 给出一个5元3次方程,输入其5个系数,求它的解的个数. 其中系数 ai∈[-50,50] 自变量xi∈[-50,0)∪(0,50] 思路: 简单暴力肯定超时的了, 暴力枚举要5层循环. 看了题解~ 原来要将方程变形: a1*x1^3 + a2*x2^3 + a3*x3^3 + a4 * x4^3 + a5*原创 2015-02-25 16:21:43 · 597 阅读 · 0 评论 -
POJ 3349 - Snowflake Snow Snowflakes(Hash)
题目: http://poj.org/problem?id=3349 题意: 给出n片六角雪花每一个角的长度, 判断是否存在两篇相似的雪花. 思路: Hash, Key = 雪花六角长度想加%100003. 若两片雪花key相同, 则判断两片雪花是否相似, 顺时针和逆时针都要判断. CODE: #include #include #include using namesp原创 2015-03-01 12:33:50 · 584 阅读 · 0 评论 -
POJ 3274 - Gold Balanced Lineup(Hash)
题目: http://poj.org/problem?id=3274 题意: 求一个最长的范围,使得二进制位上的数量相同. 思路: Hash. 一开始的想法是将每一个数转化成二进制数, 用数组记录前n个数二进制位上的个数,但是这样做是超时的. 对n个数进行处理: 7---->111---->111---->000 6---->110---->221---->110(*)原创 2015-03-01 10:06:33 · 587 阅读 · 0 评论 -
HDU 5183 - Negative and Positive (NP)(Hash)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5183 题意: 给出n个数以及k, 求出是否存在 (i,j) 使得 ai−ai+1+ai+2+⋯+(−1)j−iaj 思路: n有1e6, 暴力绝对超时. 使用输入挂 + Hash 此题要分奇数偶数判断: 从后往前枚举i, 奇数时sum-=a[i], 偶数时 sum+=a[i],原创 2015-03-08 12:19:29 · 732 阅读 · 0 评论