且未

博客园 首页 新随笔 联系 订阅 管理

08 2018 档案

摘要:(1) 字符串检索事先将已知的一些字符串(字典)的有关信息保存到trie树里,查找另外一些未知字符串是否出现过或者出现频率。举例:给出N 个单词组成的熟词表,以及一篇全用小写英文书写的文章,请你按最早出现的顺序写出所有不在熟词表中的生词。给出一个词典,其中的单词为不良... 阅读全文
posted @ 2018-08-13 10:52 阿聊 阅读(174) 评论(0) 推荐(0)

摘要:#include #include using namespace std;const int Max = 100;int N,W;int w[Max],v[Max];int f[Max][Max];int CompletePack(){ memset(f,0,... 阅读全文
posted @ 2018-08-09 11:36 阿聊 阅读(103) 评论(0) 推荐(0)

摘要:#include #include using namespace std;const int Max = 100;int N,W;int w[Max],v[Max],num[Max];int f[Max];void ZeroOnePack(int nweight,i... 阅读全文
posted @ 2018-08-09 11:29 阿聊 阅读(170) 评论(0) 推荐(0)

摘要:题目 请输出能够购买大米的最多重量,注意是重量不是价值。 把每一种物品拧出来,用01背包解决。 #include #include #include using namespace std;const int Max = 110;int N,W,w[M... 阅读全文
posted @ 2018-08-08 19:16 阿聊 阅读(106) 评论(0) 推荐(0)

摘要:两种求最长上升子序列问题第一种:定义dp[i]=以a[i]为末尾的最长上升子序列问题的长度第二种:定义dp[i]=长度为i+1的上升 子序列 中末尾元素的最小值#include #include using namespace std;const int INF =... 阅读全文
posted @ 2018-08-06 20:13 阿聊 阅读(152) 评论(0) 推荐(0)

摘要:题目题意:将N拆分成1-n个数,问有多少种组成方法。例如:N=4,将N拆分成1个数,结果就是4;将N拆分成2个数,结果就是3(即:1+3,2+2,3+1)……1+3和3+1这个算两个,则这个就是组合数问题。根据隔板定理,把N分成一份的分法数为C(1,n-1), 把N分... 阅读全文
posted @ 2018-08-04 11:04 阿聊 阅读(151) 评论(0) 推荐(0)

摘要:证明: 由欧拉定理可知 当gcd(a,n)==1 时 我们有 Aφ(n-1)≡ 1(mod n) ;所以 我们有 A*Aφ(n-2) ≡ 1(mod n) 所以Aφ(n-2) 就是A关于mod n的逆元 #include #include using nam... 阅读全文
posted @ 2018-08-03 17:02 阿聊 阅读(222) 评论(0) 推荐(0)

摘要:问题描述已知:有一个容量为V的背包和N件物品,第i件物品的重量是weight[i],价值是cost[i]。问:在不超过背包容量的情况下,最多能获得多少价值。01背包的特点:每种物品只有一件,可以选择放或者不放1子问题:f[i][v] 表示前i件物品放到一个容量为v的背... 阅读全文
posted @ 2018-08-02 16:37 阿聊 阅读(93) 评论(0) 推荐(0)

摘要:Bellman-ford:/*bellman ford*/#include #include #include using namespace std;const int INF = 0x3f3f3f3f;const int Max = 9999;typedef st... 阅读全文
posted @ 2018-08-02 10:57 阿聊 阅读(87) 评论(0) 推荐(0)

摘要:题目spfa: #include using namespace std;const int maxn = 205;const int INF = 0x3f3f3f3f;vector > E[maxn];int n,m;int d[maxn],inq[maxn];/... 阅读全文
posted @ 2018-08-02 10:51 阿聊 阅读(97) 评论(0) 推荐(0)