随笔分类 -  算法

摘要:题目 "题目地址" 思路 显然是最大子列和的进化版,那就先思考下 "经典的最大子列和" 。这也是道思维题,啥算法也没用到,全是思维技巧,真心不知道考试遇到这种题该怎么办了。 "经典的最大子列和" 只是更新了maxsub,现在可以同时更新firstElement和lastElement,最后输出即可。 阅读全文
posted @ 2016-03-04 11:05 Sundy.Lee 阅读(267) 评论(0) 推荐(0)
摘要:题目 "题目地址" 思路 用tempsum不停的更新maxsub就行了。这是道思维题,并没有什么用到经典算法。 代码 阅读全文
posted @ 2016-03-04 10:43 Sundy.Lee 阅读(345) 评论(0) 推荐(0)
摘要:mark 阅读全文
posted @ 2016-02-07 13:37 Sundy.Lee 阅读(135) 评论(0) 推荐(0)
摘要:#1038 : 01背包时间限制:20000ms单点时限:1000ms内存限制:256MB描述且说上一周的故事里,小Hi和小Ho费劲心思终于拿到了茫茫多的奖券!而现在,终于到了小Ho领取奖励的时刻了!小Ho现在手上有M张奖券,而奖品区有N件奖品,分别标号为1到N,其中第i件奖品需要need(i)张奖... 阅读全文
posted @ 2015-08-01 16:22 Sundy.Lee 阅读(217) 评论(0) 推荐(0)
摘要:对DFS解决问题的总结。自己总是忘记那些情况函数需要返回,所以特写写个模板:DFS(){ if(找到结束状态) then 返回 end if if(这个状态越界、不满足这个题意) then 返回 end if if(这个状态是访问过了) then 返回 end ... 阅读全文
posted @ 2015-07-31 16:20 Sundy.Lee 阅读(210) 评论(0) 推荐(0)
摘要:Corn FieldsTime Limit:2000MSMemory Limit:65536KTotal Submissions:9623Accepted:5092DescriptionFarmer John has purchased a lush new rectangular pasture ... 阅读全文
posted @ 2015-07-26 13:23 Sundy.Lee 阅读(265) 评论(0) 推荐(0)
摘要:在看《数论》是看到欧几里得算法可以这样写,脑洞大开。欧几里得辗转相除用于求两数的最大公约数1 int Gcd(int a,int b)2 {3 if(b==0) 4 return a;//出口5 return Gcd(b,a%b);6 7 } 阅读全文
posted @ 2015-07-26 13:10 Sundy.Lee 阅读(629) 评论(0) 推荐(0)
摘要:题目:有一个n行m列的地板,需要用 1*2小砖铺盖,小砖之间互相不能重叠,问有多少种不同的铺法?示范:解法:用F【i】【j】存放第i行的第j状态(j为十进制,转为二进制即是状态)有多少种方案。用二进制表示状态如下:其中1为放0为不放。如果上下状态兼容,那么F【i】【j】+=F【i-1】【k】 即上一... 阅读全文
posted @ 2015-07-17 20:55 Sundy.Lee 阅读(470) 评论(0) 推荐(0)
摘要:#include #include #include #include #include #include #include #define LEN 1000#define INF 99999 using namespace std;struct node{ string data; ... 阅读全文
posted @ 2015-05-21 12:24 Sundy.Lee 阅读(223) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#includeconst int MAX=50;using namespace std;int h[MAX];int N=10;//长度 void sifup(int i){ if(i==1) { return; }... 阅读全文
posted @ 2015-04-22 17:20 Sundy.Lee 阅读(356) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#includeconst int MAX=50;using namespace std;int h[MAX];void sifup(int i){ if(i==1) { return; } while(i/2!=0... 阅读全文
posted @ 2015-04-22 16:26 Sundy.Lee 阅读(569) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#include//const MAX=50;using namespace std;struct BitreeNode{ //int num=1; int data; BitreeNode *lchild; Bitre... 阅读全文
posted @ 2015-04-22 14:43 Sundy.Lee 阅读(236) 评论(0) 推荐(0)
摘要:#include#include#includeusing namespace std;//long long ct=0;//long long arr[1000]={0};int e[100][100];//存图的数组int n=0,m=0;const int inf=99999;void flo... 阅读全文
posted @ 2015-04-08 15:48 Sundy.Lee 阅读(136) 评论(0) 推荐(0)