算法学习
文章平均质量分 79
yimfeng
What hurts more, the pain of hard work or the pain of regret?
展开
-
字符串hash表示简介
字符串hash是指讲一个字符串s映射为一个整数,使得该整数可以尽可能唯一的代表字符串s。可以进行字符串的判断。代码如下:#include<iostream> #include<cstring> int hashtable[26*26*26+10]; using namespace std; int translate(string s){ int sum=...原创 2018-03-03 21:42:33 · 206 阅读 · 0 评论 -
贪心算法学习
最近刷pat,见了许多关于贪心算法的题目,刚好又读到算法笔记,就把关于贪心算法的题列出来,总结一下。pat-b-1023给定数字0-9各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意0不能做首位)。例如:给定两个0,两个1,三个5,一个8,我们得到的最小的数就是10015558。现给定数字,请编写程序输出能够组成的最小的数。输入格式:每个输入包含1个测试...原创 2018-03-03 23:08:43 · 489 阅读 · 0 评论 -
甲级pat-1087
#include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> #include<map> using namespace std; const int maxn=1000; const int INF=100...原创 2018-05-10 21:15:40 · 337 阅读 · 0 评论 -
甲级pat-a 1040
#include<iostream> #include<cstdio> using namespace std; int dp[1001][1001]; int main(){ string s; getline(cin,s); int len=s.length(),ans=1; for(int i=0;i<len;i+...原创 2018-05-21 19:32:57 · 136 阅读 · 0 评论