- 博客(9)
- 资源 (3)
- 收藏
- 关注
原创 hdu3336(KMP+DP)
题目链接:hdu3336假设两串字符完全相等,next[j]=i,代表s[1...i]==sum[j-i+1....j],这一段其实就是前缀i~j之间已经不可能有以j结尾的子串是前缀了,不然next【j】就不是 i 了设dp【i】:以string[i]结尾的子串总共含前缀的数量所以dp[j]=dp[i]+1,即以i结尾的子串中含前缀的数量加上前j个字符这一前缀#includ
2014-02-28 16:29:08 2759
原创 Sicily2501 算算式(费马小定理)
题目链接:Sicily2501题目概述:S = n^1 + n^2 + n^3 +...... + n^k,已知n、k,求S除以9901的余数。根据费马小定理:假如p是质数,且(a,p)=1(即a,p互质),那么 a^(p-1) ≡1(mod p)。即:假如p是质数,且a,p互质,那么a的(p-1)次方除以p的余数恒等于1。可知9901是质数,所以n^9900%9901=1,
2014-02-23 18:14:59 1131
原创 hdu1085(母函数解有限个硬币组合问题)
题目链接:hdu1085/*hdu 1085 Holding Bin-Laden Captive!大意: 分别给出1,2,5元硬币的个数,求用这三种硬币不能组合成的最小数值思路:母函数 三种硬币组合的情况,可以用下面三个函数的乘积表示:(1 + x + x^2 + x^3 + ... + x^f[1])(1 + x^2 + x^4 + ... + x^(f[2]*2))
2014-02-20 10:13:24 1546
原创 hdu1398(母函数模板题)
题目链接:hdu1398和hdu1028一样,直接套模板#include #include #include using namespace std;const int N = 305;int c1[N], c2[N];int main(){ int n,i,j,k; for(i = 0; i < N; i ++) c1[i] = 1, c2[
2014-02-20 08:50:54 690
原创 hdu1028 (母函数模板题)
题目链接:hdu1028母函数详解模板题, 直接套模板#include #include #include using namespace std;const int N = 125;int c1[N], c2[N];int main(){ int n,i,j,k; for(i = 0; i < N; i ++) c1[i] = 1, c2
2014-02-20 08:25:51 1281
原创 hdu1247 Hat’s Words(字典树)
题目链接:hdu1247/*大意: 如果两个单词组成的单词存在,则输出组合后的单词思路:字典树 在查找时,将一个单词分成两部分,看这两部分是否存在*/#include #include #include #include #include #include #include using namespace std;struct node{ b
2014-02-18 19:17:15 875
原创 hdu1075What Are You Talking About(字典树)
题目链接:hdu1075/*hdu 1075 What Are You Talking About(字典树)题目大意: 每行输入两个单词,第二个单词可以翻译成第一个单词。给出一串字符,能翻译的输出翻译后的单词,不能的原样输出。思路:字典树*/#include #include #include #include #include #include using
2014-02-18 09:16:07 1032
原创 hdu1251 统计难题(字典树)
题目链接:hdu1251基本的字典树,字典树又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词频统计。它的优点是:利用字符串的公共前缀来节约存储空间,最大限度地减少无谓的字符串比较,查询效率比哈希表高。#include #include #include #inc
2014-02-18 08:00:30 921
原创 hdu1874 畅通工程续(Dijkstra)
题目连接:hdu1874模板题#include #include #include #include using namespace std;const int inf = 9999999;int map[205][205];int dis[205];//表示当前点到源点的最短路int s,e,n;//s表示起点,e表示终点void dijkstra(){ bo
2014-02-17 18:33:41 642
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人