- 博客(13)
- 收藏
- 关注
原创 HDU4324-Triangle LOVE-判断是否存在环(拓扑)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4324 题目意思:矩阵。1表示i-th喜欢j-th,问是否存在环状喜欢关系。 #include #include #include #include using namespace std; const int N=2005; bool Map[N][N]; int t,n,Case=1; char
2015-11-20 22:22:55 397
原创 HDU3342-Legal or Not
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3342 思想:n个点,所以删除n次之后,在判断是否存在入度大于0的点即可。 #include #include #include #include using namespace std; const int N=105; bool Map[N][N]; bool vis[N]; struct no
2015-11-20 21:41:09 420
转载 HDU题目分类
1001 整数求和 水题 1002 C语言实验题——两个数比较 水题 1003 1、2、3、4、5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 1006 Redraiment猜想 数论:容斥定理 1007 童年生活二三事 递推题 1008 University 简单hash 1009 目标柏林 简单模拟题 1010 Rai
2015-11-20 20:52:27 739
原创 HDU2094-产生冠军-有向图
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2094 好久没有写题了。拓扑,就是有向图无向图处理入度出度的问题。 这个题目就是问你入度为0的有几个。比模板题还简单。 #include #include #include #include #include using namespace std; const int N=1005; bool
2015-11-20 20:42:19 512
原创 【AC自动机】HDU2896病毒侵袭
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2896 这个在模板的基础之上增加一个标记就可以了,保存每一个出现的病毒就可以了;所以啊,代码里的cnt是一个变化很灵活的变量; #include #include #include #include #include using namespace std; const int N=130;
2015-11-13 20:54:53 487
原创 【AC自动机】HDU2222Keywords Search
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2222 这个题目刚开始还不会,但是轮到了我给我同学讲课,之前就有看过,一直都没懂。就唯一的知道要会AC自动机,就得先会KMP和字典树。于是我就在杭电上挂了这题,默默的刷着KMP和字典树。突然要我讲课,没办法,就赶紧赶紧的临时在认真的看,分析,最后赶鸭子上架,懵懵懂懂的就上去讲了。讲着讲着发现这个模板我
2015-11-10 21:55:29 588
原创 【字典树】HDU1671Phone List(论释放内存的重要性)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1671 一道简单的模板题,但是这个题目是多组数据。所以如果你不释放内存,很有可能你就会MLE到死。。。orz.... 增加一个释放内存的函数就可以轻松搞定了。不过最好还是能够养成这样一个习惯,那就是在使用数据结构的指针是,每次都能够释放。 #include #include #include #i
2015-11-08 14:32:43 726
原创 【字典树】HDU1247Hat’s Words
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1247 #include #include #include #include using namespace std; const int N=26; char s[50005][50]; struct node { bool flag; node *next[N]; nod
2015-11-08 13:37:43 366
转载 ACM-高精度模板(综合篇)
转自:http://blog.csdn.net/u013615904/article/details/43373601 在这里,我们约定,能用int表示的数据视为单精度,否则为高精度。所有函数的设计均采用带返回值的形式。 本文包含 1.高精度加法 2.高精度减法 3.高精度乘法 1)高精度乘高精度的朴素算法 2)高精度乘高精度FFT优化算法 3)高精度乘单精度 4.高精度
2015-11-08 11:15:52 3814 1
原创 HDU3336-Count the string-KMP(next数组理解)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3336 好吧,对next数组还是没有理解到位,感觉有很多的出发点。还需要去更深的理解。 #include #include using namespace std; string str; int n,Next[200005]; void get_next() { int i=0,j=-1;
2015-11-07 14:15:37 463
原创 HDU2203-亲和串-KMP模板题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2203 其实这就是一道模板题。这个题目就只需要将第一串直接复制一份在其末尾就可以解决循环移位的所有情况。这里需要注意的就是提前判断模式串的长度大于匹配串的时候,无论怎么移位都是不可能匹配的,所以直接输出no,这样可以避免复制之后可能匹配的情况。 #include #include #include
2015-11-07 13:04:52 413
原创 HDU2087-剪花布条-KMP模板
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2087 直接匹配,匹配到一组数据,模式串就从头开始匹配; 对这个理解依旧不是特别的深刻,总觉得还是很模糊; #include #include #include #include using namespace std; const int N=10005; int Next[N]; string
2015-11-06 20:29:48 274
原创 素数测试算法-Miller-Rabin算法
对于数据太大导致无法用素数筛选法打表处理(百万级),就可以用素数测试算法。 Miller-Rabin算法是目前主流的基于概率的素数测试算法,在构建密码安全体系中占有重要的地位。通过比较各种素数测试算法和对Miller-Rabin算法进行的仔细研究,证明在计算机中构建密码安全体系时, Miller-Rain算法是完成素数测试的最佳选择。通过对Miller-Rabin 算 法底层运算的优化,可以
2015-11-01 20:45:31 1262
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人